A power supply method for a terminal device, wherein the terminal device is communicatively connected to an accessory device by an USB OTG connection, and the method comprises: • detecting, by the terminal device, an ID resistance value of the accessory device; • identifying, by the terminal device, a type of the accessory device according to the detected ID resistance value and according to a preset table of mapping between the ID resistance value of the accessory device and the type of the accessory device; • selecting, by the terminal device, a working mode from a Host mode and a Device mode according to the identified type of the accessory device from a preset working mode configuration file; • selecting, by the terminal device, a power supply mode of the terminal device according to the identified type of the accessory device irrespective of the selected working mode, the selecting comprising the steps of ∘ querying, by the terminal device, a configuration file corresponding to the identified type of the accessory device that comprises two configuration files, that is, ▪ a first configuration file for using the terminal device to power the accessory device through the VBUS line, ▪ a second configuration file for using the accessory device to power the terminal device through the VBUS line, ∘ selecting, by the terminal device, one configuration file in the accessory device randomly or preferentially as a current power supply mode; ∘ determining, by the terminal device, whether the selected configuration file runs successfully; ∘ using, by the terminal device, if the running succeeds, the selected configuration file as the current power supply mode; or ∘ selecting, by the terminal device, if the running fails, the other configuration file in the accessory device as the current power supply mode • supplying, by the terminal device, power according to the selected power supply mode. • detecting, by the terminal device, an ID resistance value of the accessory device; • identifying, by the terminal device, a type of the accessory device according to the detected ID resistance value and according to a preset table of mapping between the ID resistance value of the accessory device and the type of the accessory device; • selecting, by the terminal device, a working mode from a Host mode and a Device mode according to the identified type of the accessory device from a preset working mode configuration file; • selecting, by the terminal device, a power supply mode of the terminal device according to the identified type of the accessory device irrespective of the selected working mode, the selecting comprising the steps of ∘ querying, by the terminal device, a configuration file corresponding to the identified type of the accessory device that comprises two configuration files, that is, ▪ a first configuration file for using the terminal device to power the accessory device through the VBUS line, ▪ a second configuration file for using the accessory device to power the terminal device through the VBUS line, ∘ selecting, by the terminal device, one configuration file in the accessory device randomly or preferentially as a current power supply mode; ∘ determining, by the terminal device, whether the selected configuration file runs successfully; ∘ using, by the terminal device, if the running succeeds, the selected configuration file as the current power supply mode; or ∘ selecting, by the terminal device, if the running fails, the other configuration file in the accessory device as the current power supply mode ∘ querying, by the terminal device, a configuration file corresponding to the identified type of the accessory device that comprises two configuration files, that is, ▪ a first configuration file for using the terminal device to power the accessory device through the VBUS line, ▪ a second configuration file for using the accessory device to power the terminal device through the VBUS line, ▪ a first configuration file for using the terminal device to power the accessory device through the VBUS line, ▪ a second configuration file for using the accessory device to power the terminal device through the VBUS line, ∘ selecting, by the terminal device, one configuration file in the accessory device randomly or preferentially as a current power supply mode; ∘ determining, by the terminal device, whether the selected configuration file runs successfully; ∘ using, by the terminal device, if the running succeeds, the selected configuration file as the current power supply mode; or ∘ selecting, by the terminal device, if the running fails, the other configuration file in the accessory device as the current power supply mode • supplying, by the terminal device, power according to the selected power supply mode.