An electronic device, comprising a processor, a controller, a charging protocol chip, an external interface, and a switch circuit, wherein the processor, the charging protocol chip, and the external interface each comprise a data pin unit (111, 112; 131, 132; 141, 142); the data pin unit (111, 112) of the processor, the data pin unit (131, 132) of the charging protocol chip, the data pin unit (141, 142) of the external interface, and the controller are separately electrically connected to the switch circuit; and the controller is configured to control the switch circuit, so that the data pin unit (141, 142) of the external interface is connected to the data pin unit (131, 132) of the charging protocol chip and is disconnected from the data pin unit (111, 112) of the processor; the charging protocol chip is configured to perform second protocol identification on an external device when the external interface is connected to the external device; the controller is configured to: after receiving the indication that is sent by the charging protocol chip and that indicates that the second protocol identification fails, so that the data pin unit (141, 142) of the external interface is disconnected from the data pin unit (131, 132) of the charging protocol chip and is connected to the data pin unit (111, 112) of the processor; the processor is configured to perform first protocol identification on the external device when the external interface is connected to the external device and the data pin unit (111, 112) of the processor is connected to the pin unit (141, 142) of the external interface, wherein the first protocol comprises a USB 2.0 protocol, and a second protocol comprises an SCP/FCP fast charging protocol. the processor, the charging protocol chip, and the external interface each comprise a data pin unit (111, 112; 131, 132; 141, 142); the data pin unit (111, 112) of the processor, the data pin unit (131, 132) of the charging protocol chip, the data pin unit (141, 142) of the external interface, and the controller are separately electrically connected to the switch circuit; and the controller is configured to control the switch circuit, so that the data pin unit (141, 142) of the external interface is connected to the data pin unit (131, 132) of the charging protocol chip and is disconnected from the data pin unit (111, 112) of the processor; the charging protocol chip is configured to perform second protocol identification on an external device when the external interface is connected to the external device; the controller is configured to: after receiving the indication that is sent by the charging protocol chip and that indicates that the second protocol identification fails, so that the data pin unit (141, 142) of the external interface is disconnected from the data pin unit (131, 132) of the charging protocol chip and is connected to the data pin unit (111, 112) of the processor; the processor is configured to perform first protocol identification on the external device when the external interface is connected to the external device and the data pin unit (111, 112) of the processor is connected to the pin unit (141, 142) of the external interface, wherein the first protocol comprises a USB 2.0 protocol, and a second protocol comprises an SCP/FCP fast charging protocol.