Mode switching method and terminal device

By using an asynchronous close thread in the terminal device to close the current shooting mode and start the open thread of the next mode, the problem of slow switching speed of shooting mode in the existing technology is solved, and faster mode switching and better user experience are achieved. .

WO2024179049A9PCT designated stage expired Publication Date: 2024-10-17HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/132369
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-02-27
Filing Date
2023-11-17
Publication Date
2024-10-17

AI Technical Summary

Technical Problem

Existing terminal devices are slow when switching shooting modes, which affects the user experience. This is mainly due to the long waiting time caused by the system resource supply status.

Method used

By creating an asynchronous close thread in the terminal device to close the current shooting mode, and starting the open thread of the next shooting mode during the execution of this thread, asynchronous processing is achieved, thereby reducing waiting time and increasing switching speed.

Benefits of technology

It improves the speed of shooting mode switching and improves the user experience, especially the efficiency when quickly switching between multiple shooting modes after booting or restarting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023132369_17102024_PF_FP_ABST
    Figure CN2023132369_17102024_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are a mode switching method and a terminal device, which are beneficial to improving the speed of a camera application switching a camera mode. The method comprises: in response to an operation of opening a camera application, displaying a first interface of the camera application, wherein the first interface is an interface of a photographing mode; in response to an operation of switching a camera mode to a multi-lens video recording mode at a first time point, displaying a second interface of the camera application at a second time point, wherein the second interface is an interface of the multi-lens video recording mode, and a first time period and a second time period overlap between the first time point and the second time point, the first time period being a time period for turning off the photographing mode on the basis of a turn-off thread, and the second time period being a time period for activating the multi-lens video recording mode on the basis of an activation thread; and in response to an operation of switching the camera mode to the photographing mode at a third time point, displaying a third interface of the camera application at a fourth time point, wherein the third interface is the interface of the photographing mode.
Need to check novelty before this filing date? Find Prior Art

Description

Mode switching method and terminal device

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on February 27, 2023, with application number 202310208362.9 and application name “Mode Switching Method and Terminal Device”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of terminals, and in particular to a mode switching method and terminal device. Background Art

[0003] Currently, the camera applications of most terminal devices support multiple shooting modes, such as photo mode, video mode, portrait mode, etc. Users can freely choose the shooting mode and experience different shooting effects.

[0004] When the user turns on the phase switch shooting mode, due to the influence of the system resource supply status, the speed of switching shooting mode is slow, affecting the user experience.

[0005] Summary of the Invention

[0006] The present application provides a mode switching method and terminal device, which are conducive to improving the speed of switching shooting modes and enhancing the user experience.

[0007] In a first aspect, the present application provides a mode switching method, which can be executed by a terminal device, and the method includes: in response to an operation of opening a camera application, displaying a first interface of the camera application, the first interface being an interface of the photo mode; in response to an operation of switching the shooting mode to the multi-lens recording mode at a first time point, displaying a second interface of the camera application at a second time point, the second interface being an interface of the multi-lens recording mode; between the first time point and the second time point, there is overlap between the first time point and the second time point; the first time period is a time period for closing the photo mode based on the closing thread, and the second time period is a time period for starting the multi-lens recording mode based on the starting thread; in response to an operation of switching the shooting mode to the photo mode at a third time point, displaying a third interface of the camera application at a fourth time point, the third interface being an interface of the photo mode; between the third time point and the fourth time point, there is no overlap between the third time point and the fourth time point; the third time period is a time period for closing the multi-lens recording mode based on the closing thread, and the fourth time period is a time period for starting the shooting mode based on the starting thread.

[0008] In this application, the close thread is used to close a shooting mode, which may specifically include releasing the camera service resources of the shooting mode. The start (open) thread is used to start a shooting mode.

[0009] It should be understood that after the terminal device is powered on or restarted, the terminal device will create a first close thread, an open thread, and a configure_streams (configure stream) thread for the camera application, and wait for the camera application to issue an instruction to call them.

[0010] Considering that there is no coupling between closing the photo mode based on the close thread and starting the multi-lens recording mode based on the open thread, based on the technical solution of the present application, the terminal device can create a second close thread when the camera application calls the close interface. The second close thread can also be called an asynchronous close thread. The terminal device closes the photo mode based on the asynchronous close thread. In other words, the close process of the photo mode is carried out in the asynchronous close thread.

[0011] In the process of closing the photo mode based on the asynchronous close thread, the terminal device can start the multi-camera recording mode based on the open thread. That is, the open thread used to start the multi-camera recording mode does not need to wait for the close thread used to close the photo mode to end before it can be executed, thereby realizing the simultaneous execution of the asynchronous close thread and the open thread. Therefore, between the first time point and the second time point, the time for closing the photo mode based on the closing thread (here is the asynchronous close thread) and the time for starting the multi-camera recording mode based on the starting thread overlap, which improves the speed of switching the shooting mode, thereby improving the user experience.

[0012] However, not all shooting modes can release camera service resources by creating an asynchronous close thread. For example, in the scenario where the shooting mode is switched from multi-lens recording mode to photo mode, the multi-lens recording mode does not support the creation of an asynchronous close process. Therefore, the terminal device closes the multi-lens recording mode based on the first close thread, and after the first close thread ends, starts the photo mode based on the open thread. In other words, the first close thread and the open thread are executed serially. Therefore, between the third time point and the fourth time point, there is no overlap between the time when the multi-lens recording mode is closed based on the closing thread (here is the first close thread) and the time when the photo mode is started based on the starting thread.

[0013] In conjunction with the first aspect, in certain implementations of the first aspect, in response to switching the shooting mode to the photo mode at the third time point, after displaying the third interface of the camera application at the fourth time point, the method further includes: switching the shooting mode to the video recording mode at the fifth time point; before configuring resources for the video recording mode, switching the shooting mode to the photo recording mode at the sixth time point; between the fifth time point and the sixth time point, the fifth time period and the sixth time period do not overlap; the fifth time period is a time period for shutting down the video recording mode based on the shutdown thread, and the sixth time period is a time period for shutting down the photo recording mode based on the startup thread. It should be noted that the shutdown thread in this implementation is the first close thread.

[0014] In conjunction with the first aspect, in certain implementations of the first aspect, after responding to an operation of switching the shooting mode to the multi-camera recording mode at a first time point, the method further includes: creating a close thread; and closing the shooting mode based on the close thread. It should be noted that the close thread in this implementation is an asynchronous close thread.

[0015] In combination with the first aspect, in certain implementations of the first aspect, creating a close thread includes: creating a close thread when preset conditions are met. The preset conditions include: the application package name indicated by the first preconfiguration parameter includes the application package name of the camera application, the shooting mode indicated by the second preconfiguration parameter does not include the photo mode, the last close thread at the current moment (here is the asynchronous close thread when the shooting mode was last switched) is in an idle state, and the CHI module has been initialized. Among them, the first preconfiguration parameter is used to indicate the application package name that can support the creation of a close thread, and the second preconfiguration parameter is used to indicate the shooting mode that does not support the creation of a close thread. It should be noted that the close thread in this implementation is an asynchronous close thread.

[0016] In conjunction with the first aspect, in certain implementations of the first aspect, after creating a shutdown thread when a preset condition is met, the method further includes: starting a multi-camera recording mode based on the startup thread; after the multi-camera recording mode is started, if the shutdown thread is completed, starting a stream configuration thread to configure resources for the multi-camera recording mode; and displaying a second interface of the camera application at a second time point, including: after the stream configuration thread is completed, displaying the second interface of the camera application at the second time point. It should be noted that the shutdown thread in this implementation is an asynchronous close thread.

[0017] In conjunction with the first aspect, in certain implementations of the first aspect, after the multi-camera recording mode is activated, the method further includes: obtaining a thread status of a closing thread; and determining whether the closing thread is complete based on the thread status of the closing thread. It should be noted that the closing thread in this implementation is an asynchronous close thread.

[0018] In conjunction with the first aspect, in certain implementations of the first aspect, determining whether thread closure is complete based on the thread state of the closing thread includes: determining that thread closure is complete if the thread state of the closing thread is terminated; and determining that thread closure is incomplete if the thread state of the closing thread is not terminated. It should be noted that the closing thread in this implementation is an asynchronous close thread.

[0019] In a second aspect, the present application provides a terminal device, comprising: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the terminal device performs the method of the first aspect.

[0020] In a third aspect, the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method of the first aspect.

[0021] In a fourth aspect, the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the method of the first aspect.

[0022] In a fifth aspect, the present application provides a chip, the chip including a processor, the processor being used to call a computer program in a memory to execute the method described in the first aspect.

[0023] It should be understood that the second to fifth aspects of the present application correspond to the technical solutions of the first or second aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] FIG1 is a schematic structural diagram of a terminal device applicable to an embodiment of the present application;

[0025] FIG2 is a software structure block diagram of a terminal device to which an embodiment of the present application is applicable;

[0026] FIG3 is a schematic diagram of a mode switching interface provided by an embodiment of the present application;

[0027] FIG4 is a schematic diagram of a mode switching provided by an embodiment of the present application;

[0028] FIG5 is a schematic diagram of another mode switching provided by an embodiment of the present application;

[0029] FIG6 is a schematic flow chart of a mode switching method provided in an embodiment of the present application;

[0030] FIG7 is a schematic flow chart of another mode switching method provided in an embodiment of the present application;

[0031] FIG8 is a schematic diagram of another mode switching interface provided by an embodiment of the present application;

[0032] FIG9 is a schematic flowchart of another mode switching method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0033] The technical solution in this application will be described below with reference to the accompanying drawings.

[0034] In order to clearly describe the technical solutions of the embodiments of the present application, the relevant terms involved in the present application are first introduced in detail below.

[0035] In the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects, and do not limit their order. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity or execution order, and words such as "first" and "second" do not necessarily mean different.

[0036] It should be noted that, in this application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described in this application as "exemplary" or "for example" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplarily" or "for example" is intended to present the relevant concepts in a concrete manner.

[0037] In addition, "at least one" means one or more, and "more" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b and c can mean: a, or b, or c, or a and b, or a and c, or b and c, or a, b and c, where a, b, c can be single or multiple.

[0038] FIG1 is a schematic diagram of the structure of a terminal device applicable to an embodiment of the present application. As shown in FIG1 , the terminal device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a USB interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identity module (SIM) card interface 195, etc.

[0039] It should be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0040] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, a display processing unit (DPU), and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors. In some embodiments, the terminal device 100 may also include one or more processors 110. The processor may serve as the nerve center and command center of the terminal device 100. The processor may generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution. The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory may store instructions or data used or recycled by the processor 110. If the processor 110 needs to use the instruction or data again, it can directly call it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110 , and thus improves the efficiency of the terminal device 100 .

[0041] The wireless communication functionality of terminal device 100 can be implemented using antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, a modem processor, and a baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0042] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the terminal device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier, etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0043] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. applied to the terminal device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0044] In some embodiments, the antenna 1 of the terminal device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the terminal device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include GSM, GPRS, CDMA, WCDMA, TD-SCDMA, LTE, GNSS, WLAN, NFC, FM, and / or IR technology. The above-mentioned GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite-based augmentation system (SBAS).

[0045] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, terminal device 100 may include one or N display screens 194, where N is a positive integer greater than 1.

[0046] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, data files such as music, photos, and videos can be stored on the external memory card.

[0047] The internal memory 121 can be used to store one or more computer programs, each of which includes instructions. The processor 110 can execute the instructions stored in the internal memory 121, thereby enabling the terminal device 100 to perform various functional applications and data processing. The internal memory 121 may include a program storage area and a data storage area. The program storage area may store an operating system; the program storage area may also store one or more applications (such as a gallery, contacts, etc.). The data storage area may store data created during the use of the terminal device 100 (such as photos, contacts, etc.). In addition, the internal memory 121 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. In some embodiments, the processor 110 can execute the instructions stored in the internal memory 121 and / or the instructions stored in the memory provided in the processor 110, thereby enabling the terminal device 100 to perform various functional applications and data processing.

[0048] The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.

[0049] In addition, on top of the above components, an operating system, such as an iOS operating system, an Android operating system, a Windows operating system, etc., runs in the terminal device 100. Applications can be installed and run on the operating system. In other embodiments, there can be multiple operating systems running in the terminal device 100.

[0050] It should be understood that the hardware modules included in the terminal device shown in Figure 1 are merely illustrative and do not limit the specific structure of the terminal device. In fact, the terminal device provided in the embodiments of the present application may also include other hardware modules that interact with the hardware modules illustrated in the figure, which are not specifically limited here. For example, the terminal device may also include a flashlight, a micro-projector, etc. For another example, if the terminal device is a personal computer (PC), then the terminal device may also include components such as a keyboard and a mouse.

[0051] The software system of the terminal device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a microservice architecture, or a cloud architecture. In the embodiment of the present application, the Android system with a layered architecture is used as an example to illustrate the software structure of the terminal device 100.

[0052] Figure 2 is a software structure diagram of a terminal device to which an embodiment of the present application is applicable. The layered architecture divides the software system of the terminal device 100 into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system may include an application layer (application, APP), an application framework layer (application framework), a hardware abstraction layer (hardware abstraction layer, HAL) and a kernel layer (kernel). In some embodiments, the terminal device also includes a hardware layer (e.g., a display screen). In some embodiments, the Android system also includes an Android runtime (Android runtime) and a system library.

[0053] For example, the application layer can include a series of application packages, which run applications by calling the application programming interface (API) provided by the application framework layer. As shown in Figure 2, the application package may include applications such as camera, calendar, map, phone, music, WLAN, Bluetooth, video, social networking, gallery, navigation, and short messaging.

[0054] The application framework layer provides application programming interfaces (APIs) and programming services for applications in the application layer. The framework layer includes some predefined functions. The framework layer provides programming services to the application layer through the API interface. It should be noted that in an embodiment of the present application, the programming service can be, for example, a camera service. In some embodiments, as shown in Figure 2, the framework layer includes a camera service framework and a media framework. Among them, the media framework includes an encoder.

[0055] The hardware abstraction layer is an interface layer between the kernel layer and the hardware, and can be used to abstract the hardware. For example, as shown in FIG2 , the hardware abstraction layer includes a camera interface.

[0056] The kernel layer provides the underlying drivers for various hardware components of the phone. For example, as shown in Figure 2, the kernel layer includes a camera driver module. The kernel layer also includes a process and thread manager, responsible for creating and terminating processes and threads. The kernel layer provides the underlying support for processes and threads.

[0057] The terminal devices in the embodiments of the present application may also be referred to as terminals, user equipment (UE), mobile stations (MS), mobile terminals (MT), etc. The terminal devices may be mobile phones, PCs, smart TVs, wearable devices, tablet computers, computers with wireless transceiver functions, virtual reality (VR) terminal devices, augmented reality (AR) terminal devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, etc.

[0058] As an example and not a limitation, in the embodiment of the present application, the terminal device may also be a wearable device. Wearable devices may also be called wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include those that are fully functional, large in size, and can achieve complete or partial functions without relying on smartphones, such as smart watches or smart glasses, as well as those that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.

[0059] In addition, the terminal device can also be a terminal device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection. This application does not limit the specific form of the terminal device. It should be understood that in the embodiment of the present application, the terminal device can be a device for realizing the function of the terminal device, or it can be a device that can support the terminal device to realize the function, such as a chip system, which can be installed in the terminal. In the embodiment of the present application, the chip system can be composed of chips, or it can include chips and other discrete devices.

[0060] Figure 3 is a schematic diagram of a mode switching interface provided by an embodiment of the present application, including Interface A, Interface B, and Interface C. Taking a mobile phone as an example, in response to a user clicking the camera application icon on Interface A, the phone displays the photo taking interface shown in Interface B. Interface B includes a preview area 01 and a shooting mode selection area 02. Preview area 01 displays a preview of the subject to be photographed, and the user can select control 03 on Interface B to capture the subject.

[0061] For example, the user may click on a certain shooting mode in the shooting mode selection area 02 to switch the shooting mode, or the user may slide left or right in the shooting mode selection area 02 to switch the shooting mode.

[0062] For example, the camera application can support multiple shooting modes, such as photo, video, multi-lens video (also called multi-view video), time-lapse photography, ultra-wide angle, large aperture, night mode, portrait mode, etc. The shooting mode of the camera application in interface B is photo.

[0063] In response to the user selecting the recording mode in interface B, the mobile phone displays the recording interface shown in interface C. The preview area 01 can display a preview of the object to be photographed, and the user can select control 03 in interface C to record the object to be photographed.

[0064] Based on the software architecture of the terminal device described in FIG2 and the scenario of the camera application switching from the photo mode to the video mode described in FIG3 , a schematic diagram of the mode switching is introduced below in conjunction with FIG4 .

[0065] As shown in Figure 4, when the camera application switches from photo mode to video mode, it first calls the hardware abstraction layer's close procedure to close the photo mode. This process may include releasing the channels established and resources requested by the photo mode, such as subsystem services, memory resources, and input / output (I / O) resources. After closing the photo mode, the camera application calls the hardware abstraction layer's open procedure to start the camera application's video mode and obtain camera parameters and resources. After the start procedure completes, the camera application calls the hardware abstraction layer's configure_streams procedure to configure the platform session, pipeline, and node, and perform hardware initialization, such as initializing the camera sensor and configuring the video stream to be displayed. The camera application then sends a repeating command to the hardware abstraction layer to request images captured by the camera sensor. The hardware abstraction layer returns multiple frames of images to the camera application, which then displays the preview image in the preview area. The process of switching between photo modes shown in Figure 4 takes approximately 810ms.

[0066] During the aforementioned mode switching process, the camera application first flushes the camera's usecase resources and then calls the close process to close the photo mode. After the photo mode close process is completed, the camera application calls the open process to start the video mode. After the video mode start process is completed, the camera application calls the configure_streams process to configure the platform session, pipeline, and node. The photo mode close process and the video mode open process are executed serially. In other words, the camera application calls the open process to start the video mode only after the photo mode close process is completed. For some terminal devices with poor performance, when the camera application's photo mode is closed, operations such as memory release, thread scheduling, and data processing cannot obtain central processing unit (CPU) resources in a timely manner. This will result in a longer time to close the photo mode, reduce the switching speed of the shooting mode, and thus affect the user experience.

[0067] In view of this, an embodiment of the present application provides a mode switching method, taking into account that there is no coupling between the close process of the previous shooting mode (such as the photo mode in Figure 3) and the open process of the next shooting mode (such as the video recording mode in Figure 3), therefore, the terminal device can create an asynchronous close thread when the camera application calls the close interface, and the asynchronous close thread is used to close the previous shooting mode. The camera application can start the next shooting mode based on the open thread in the process of closing the previous shooting mode based on the asynchronous close thread. In this way, the close process of the previous shooting mode and the open process of the next shooting mode can be carried out at the same time, reducing the time waiting for the close process of the previous shooting mode to be completed, and thus it is beneficial to improve the switching speed of the shooting mode, thereby improving the user experience.

[0068] The previous shooting mode and the next shooting mode described in the embodiments of the present application are relative to before and after the operation of switching the shooting mode is performed. The shooting mode before the operation of switching the shooting mode is performed is the previous shooting mode, and the shooting mode after the operation of switching the shooting mode is performed is the next shooting mode.

[0069] It should be noted that the close process in the embodiment of the present application refers to the process of closing a shooting mode based on the close thread (the asynchronous close thread or the first close thread in this article), and the process of closing a shooting mode based on the asynchronous close thread can also be called an asynchronous close process; the open process refers to the process of starting a shooting mode based on the open thread; the configure_streams process refers to the process of configuring camera service resources for a shooting mode based on the configure_streams thread.

[0070] Based on the software architecture of the terminal device described in FIG2 and the scenario of the camera application switching from the photo mode to the video mode described in FIG3 , another flowchart of switching the shooting mode is described below in conjunction with FIG5 .

[0071] Figure 5 is a schematic diagram of another mode switching provided by an embodiment of the present application. As shown in Figure 5, the camera application first calls the close process of the hardware abstraction layer to close the photo mode, and the hardware abstraction layer creates an asynchronous close thread to carry the closing process of the photo mode. While the closing process is in progress, the camera application calls the open process of the hardware abstraction layer to start the recording mode of the camera application. After the startup process is completed, the camera application calls the configure_streams process of the hardware abstraction layer to configure the platform session, pipeline and node, and initialize the camera sensor and configure the recording stream to be displayed. Afterwards, the camera application requests the hardware abstraction layer to draw the image, and the hardware abstraction layer returns multiple frames of images to the camera application. The camera application displays the preview screen in the preview area based on the multiple frames of images. The process of switching the shooting mode shown in Figure 5 takes approximately 700ms.

[0072] Figure 5 is a schematic diagram of switching shooting modes using an asynchronous close thread provided in an embodiment of the present application. By comparing Figures 4 and 5, it can be seen that since the closing process of the shooting mode is carried out in the asynchronous close thread, the camera application can quickly call the startup process of the video recording mode without waiting for the closing process of the shooting mode to end. The closing process of the shooting mode and the startup process of the video recording mode can be executed at the same time, which improves the speed of switching the shooting mode.

[0073] 2 , FIG6 is a flowchart of a more detailed mode switching method 600 provided based on FIG5 . The steps of method 600 may be interactively executed by the camera application, application framework layer, hardware abstraction layer, and kernel layer shown in FIG2 .

[0074] The application layer and the hardware abstraction layer need to go through the Java native interface (JNI) of the application framework layer to convert the Java instructions of the application layer into C++ instructions that the hardware abstraction layer can recognize. The JNI interface includes the close interface, the open interface, and the configure_streams interface.

[0075] In the embodiment depicted in FIG6 , the first shooting mode represents the previous shooting mode or the shooting mode before switching (e.g., the photo mode in FIG3 ), and the second shooting mode represents the next shooting mode or the shooting mode after switching (e.g., the video recording mode in FIG3 ). Here, the first shooting mode is the photo mode, and the second shooting mode is the video recording mode. Furthermore, the second shooting mode may also be another mode, such as the multi-camera video recording mode, without limitation.

[0076] It should be understood that the transmission between layers or modules in the embodiments of the present application is actually achieved through function calls.

[0077] The method 600 includes steps S601 to S630, and the specific steps are as follows:

[0078] S601, in response to the user's operation of switching the first shooting mode to the second shooting mode in the camera interface, the camera application sends a mode switching instruction to the application framework layer, where the mode switching instruction is used to instruct the camera application to switch the first shooting mode to the second shooting mode.

[0079] Optionally, the com.hihonor.camera process of the camera application sends the mode switching instruction to the camera server process of the application framework layer by calling the close interface of the application framework layer.

[0080] S602: The application framework layer sends the mode switching instruction to the hardware abstraction layer.

[0081] Optionally, the application framework layer sends the mode switching instruction to the android.hardware.camera.provider@2.4-server_64 process (hereinafter referred to as the provider process) of the hardware abstraction layer through the close interface.

[0082] After S601 and S602 , the camera application can pass the mode switching instruction to the hardware abstraction layer by calling the close interface of the application framework layer, so as to call the close thread of the hardware abstraction layer to close the first shooting mode.

[0083] It should be understood that after the terminal device is powered on or restarted, the provider process of the hardware abstraction layer will create the first close thread, open thread and configure_streams thread for the camera application, waiting for the camera application to issue instructions to call them.

[0084] S603: The hardware abstraction layer determines whether the conditions for creating an asynchronous close thread are met. If so, the process proceeds to S604.

[0085] It should be noted that the asynchronous close thread in this application can also be referred to as the second close thread. The first close thread and the second close thread are two different threads.

[0086] In this step, the asynchronous close thread is used to close the first shooting mode and release the camera service resources requested by the first shooting mode. Optionally, determining whether to create an asynchronous close thread requires considering the following pre-set conditions: whether the current application package name and the current application's shooting mode meet the requirements for creating an asynchronous close thread, whether the asynchronous close thread from the last mode switch (referred to as the last asynchronous close thread) is idle at the current moment, and the current initialization status of the CHI module.

[0087] The situations where the preset conditions are met include: the current application package name and the current application shooting mode meet the requirements for creating an asynchronous close thread, the last asynchronous close thread is in an idle state at the current moment, and the CHI module has been initialized.

[0088] Optionally, when determining whether the current application package name and shooting mode meet the requirements for creating an asynchronous close thread, the hardware abstraction layer can check the configuration parameters in the product.xml file to determine whether the switch for the asynchronous close thread is turned on, whether the application package name matches the configured application package name, and whether the shooting mode of the current application supports the creation of an asynchronous close thread. It should be noted that the current application in the embodiment of the present application is a camera application, the current application package name is the application package name of the camera application, and the shooting mode of the current application refers to the previous shooting mode of the camera application, that is, the first shooting mode in the embodiment of the present application.

[0089] For example, the "isAvailable" parameter in the configuration parameters in the product.xml file is the main switch for configuring the asynchronous close thread. When the "isAvailable" parameter is configured to "0", it means that the switch of the asynchronous close thread is not turned on; when the "isAvailable" parameter is configured to "1", it means that the switch of the asynchronous close thread is turned on.

[0090] For example, the "avoidMode" parameter (also known as the second pre-configured parameter) in the product.xml file indicates that certain camera application shooting modes do not implement or support the creation of asynchronous close threads. For example, shooting modes that do not support the creation of asynchronous close threads include multi-camera recording. To obtain the "avoidMode" parameter, you need to query the camera application or print the value of the "tag:cameraSceneMode" in the hardware abstraction layer.

[0091] Exemplarily, the "supportAppNameList" parameter (which may be referred to as the first pre-configured parameter) in the product.xml file indicates the pre-configured application package names that can support the creation of asynchronous close threads.

[0092] Optionally, when determining whether the last asynchronous close thread is in an idle state, the hardware abstraction layer may determine this based on whether the global handle of the asynchronous thread is null. If the global handle of the last asynchronous close thread is null, it indicates that the last asynchronous close thread is in an idle state, that is, the last asynchronous close thread has been completed; if the global handle of the last asynchronous close thread is not null, it indicates that the last asynchronous close thread is not in an idle state, that is, the last asynchronous close thread has not been completed.

[0093] It should be noted that if the previous asynchronous close thread is not completed before the current asynchronous close thread is started, the two asynchronous close threads may operate on the same data structure or global variable at the same time, causing data confusion and thread safety issues. Therefore, determining whether the previous asynchronous close thread is idle here can avoid data confusion and improve the safety of the current asynchronous close thread.

[0094] Optionally, in some abnormal or testing scenarios, the terminal device immediately starts the close process for the second shooting mode after opening the open process, without executing the configure_streams process for the second shooting mode. This means that the corresponding resources for the second shooting mode are not configured, and there is no need to release the resources for the second shooting mode. This situation is an abnormal camera process. In this abnormal camera process, since there is no need to release resources, the execution speed of the close process for the second shooting mode can be accelerated, and no asynchronous close thread is created to carry out the close process of the second shooting mode.

[0095] Optionally, the hardware abstraction layer can determine whether the current camera process is normal by detecting the initialization status of the current CHI module. The initialization of the CHI module is related to the configure_streams process. If the terminal device does not execute the configure_streams process, the CHI module is not initialized. If the terminal device executes the configure_streams process, the CHI module will be initialized. Exemplarily, the terminal device can set a flag bit to indicate the initialization status of the CHI module. When the flag bit is "true", it indicates that the CHI module has been initialized; when the flag bit is "false", it indicates that the CHI module has not been initialized.

[0096] Optionally, the hardware abstraction layer may configure thread attributes and priorities for the asynchronous close thread when creating the asynchronous close thread to ensure that the asynchronous close thread works properly.

[0097] Optionally, if the hardware abstraction layer determines that the conditions for creating an asynchronous close thread are not met, the terminal device executes the process of switching shooting modes as described in Figure 4, and does not create an asynchronous close thread. The camera application calls the established close thread in the hardware abstraction layer to execute the close process of the first shooting mode. After the close process of the first shooting mode ends, the open process of the second shooting mode is executed.

[0098] S604: The hardware abstraction layer sends an instruction to the kernel layer to create an asynchronous close thread.

[0099] Optionally, the hardware abstraction layer sends the instruction to create the asynchronous close thread to the kernel layer by calling an application programming interface (API) interface provided by the kernel layer. Exemplarily, the API interface provided by the kernel layer is a "thread_create" interface.

[0100] S605: The kernel layer creates an asynchronous close thread.

[0101] Optionally, the hardware abstraction layer writes parameters for creating an asynchronous close thread in the API interface, and the kernel layer's thread manager creates the asynchronous close thread based on the parameters in the API interface. After the asynchronous close thread is created, the kernel layer's thread manager starts the asynchronous close thread to release camera service resources for the first shooting mode.

[0102] S606: The kernel layer starts an asynchronous close thread to execute the close process of the first shooting mode.

[0103] Taking the Android system as an example, processes and threads are managed by the kernel layer's thread manager. The thread manager is responsible for assigning processes or threads to the CPU for execution, and the CPU executes the processes or threads assigned by the thread manager. Optionally, the kernel layer initiates an asynchronous close thread, including: the kernel layer's thread manager assigns the asynchronous close thread to the CPU, and the CPU initiates the asynchronous close thread to release camera service resources for the first shooting mode.

[0104] S607: The kernel layer sends the creation result to the hardware abstraction layer.

[0105] In this step, the creation result indicates that the asynchronous close thread has been created.

[0106] S608: The hardware abstraction layer sends a first feedback result (result) to the application framework layer, indicating that the close process of the first shooting mode has been completed.

[0107] In this step, after receiving the creation result, the hardware abstraction layer does not need to wait for the close process of the first shooting mode to complete. Instead, it immediately returns the first feedback result to the application framework layer by calling the application framework layer's close interface. It should be understood that the hardware abstraction layer returns the first feedback result to the application framework layer based on the first close thread, while the asynchronous close thread used to close the first shooting mode is still in progress.

[0108] S609: The application framework layer sends a first feedback result to the camera application.

[0109] After S608 and S609, the hardware abstraction layer can pass the first feedback result to the camera application by calling the close interface of the application framework layer. After receiving the first feedback result, the camera application can execute S610. The open process does not need to wait for the close process to complete, achieving asynchronous close and open thread execution simultaneously.

[0110] S610: The camera application sends an instruction to execute an open process to the application framework layer. The instruction to execute the open process is used to instruct to start an open thread of the second shooting mode.

[0111] Optionally, the com.hihonor.camera process of the camera application sends the instruction to execute the open process to the camera server process of the application framework layer by calling the open interface of the application framework layer.

[0112] S611, the application framework layer sends the instruction to execute the open process to the hardware abstraction layer.

[0113] Optionally, the application framework layer sends the instruction to execute the open process to the provider process of the hardware abstraction layer through the open interface.

[0114] After S610 and S611 , the camera application can pass the instruction to execute the open process to the hardware abstraction layer by calling the open interface of the application framework layer, thereby starting the open thread of the hardware abstraction layer to execute the open process of the second shooting mode.

[0115] S612: The hardware abstraction layer sends an instruction to start an open thread to the kernel layer. The instruction to start an open thread is used to instruct the kernel layer to start an open thread to execute an open process of the second shooting mode.

[0116] S613: The kernel layer starts an open thread to execute the open process of the second shooting mode.

[0117] Optionally, the kernel layer starts an open thread, including: a thread manager of the kernel layer assigns the open thread to a CPU, and the CPU starts executing an open process of the second shooting mode and configuring camera parameters and resources of the second shooting mode.

[0118] S614: After the open process of the second shooting mode is completed, the kernel layer sends a second feedback result to the hardware abstraction layer.

[0119] In this step, the second feedback result is used to indicate that the open process of the second shooting mode has ended.

[0120] S615: The hardware abstraction layer sends the second feedback result to the application framework layer.

[0121] S616: The application framework layer sends the second feedback result to the camera application.

[0122] S617: The camera application sends an instruction to execute the configure_streams process to the application framework layer. The instruction to execute the configure_streams process is used to instruct to start the configure_streams thread of the second shooting mode.

[0123] S618: The application framework layer sends the instruction to execute the configure_streams process to the hardware abstraction layer.

[0124] Optionally, the application framework layer sends the instruction for executing the configure_streams process to the provider process of the hardware abstraction layer through the configure_streams interface.

[0125] After S617 and S618, the camera application can pass the instruction to execute the configure_streams process to the hardware abstraction layer by calling the configure_streams interface of the application framework layer, thereby starting the configure_streams thread of the hardware abstraction layer to execute the configure_streams process of the second shooting mode.

[0126] S619: The hardware abstraction layer detects whether the asynchronous close thread is finished.

[0127] In this step, after receiving the instruction to execute the configure_streams process from the application framework layer, the hardware abstraction layer first detects whether the asynchronous close thread has ended, that is, detects whether the resource release based on the asynchronous close thread is complete. After determining that the asynchronous close thread has ended, the hardware abstraction layer instructs the kernel layer to start the configure_streams thread. Since the asynchronous close thread and the configure_streams thread are highly coupled in channel creation and memory application, for example, if both apply for the same memory space, the memory space applied for the second shooting mode may be released by the asynchronous close thread, causing the camera application to obtain the camera service resources for the second shooting mode abnormally. Therefore, before instructing the kernel layer to start the configure_streams thread, the hardware abstraction layer needs to first detect whether the asynchronous close thread has ended, and then start the configure_streams thread if the asynchronous close thread has ended. This is conducive to the camera application to normally obtain the camera service resources for the second shooting mode and avoid abnormalities in the camera process.

[0128] As can be seen from the description of S606 , the thread manager of the kernel layer assigns the asynchronous close thread to the CPU, and the CPU executes the asynchronous close thread of the first shooting mode to release the camera service resources of the first shooting mode.

[0129] For example, in the code logic, the hardware abstraction layer can configure thread blocking in the configure_streams process. If the asynchronous close thread has not ended, but the camera application has been scheduled to the configure_streams process, then during the execution of the configure_streams process, the hardware abstraction layer detects whether the asynchronous close thread is completed. If not, the hardware abstraction layer instructs the thread manager not to assign the configure_streams thread to the CPU by calling the sleep interface of the thread manager. After waiting for the asynchronous close thread to complete, the hardware abstraction layer instructs the thread manager to assign the configure_streams thread to the CPU, and the CPU executes the configure_streams process; if it has been completed, the hardware abstraction layer instructs the kernel layer to start the configure_streams thread.

[0130] From the beginning to the end, the asynchronous close thread has different thread states, such as the initial state (new), the running state (runnable), the waiting state (waiting), and the terminated state (terminated). When detecting whether the asynchronous close thread has ended, the hardware abstraction layer calls the thread manager's pthread_join interface, instructing the thread manager to check the CPU's stack to see if the asynchronous close thread's thread state is terminated. When the hardware abstraction layer calls the pthread_join interface in the configure_streams thread, the configure_streams thread will be blocked until the CPU returns a termination instruction to the thread manager through the pthread_join interface, indicating that the asynchronous close thread's thread state is terminated. At this point, the configure_streams thread will continue to execute. After receiving the termination instruction through the pthread_join interface, the thread manager notifies the hardware abstraction layer that it can continue executing the configure_streams thread.

[0131] S620: When the asynchronous close thread ends, the hardware abstraction layer sends an instruction to start the configure_streams thread to the kernel layer. The instruction to start the configure_streams thread is used to instruct the kernel layer to start the configure_streams thread to execute the configure_streams process of the second shooting mode.

[0132] S621: The kernel layer starts the configure_streams thread to execute the configure_streams process of the second shooting mode.

[0133] Optionally, the kernel layer starts the configure_streams thread, including: the thread manager of the kernel layer assigns the configure_streams thread to the CPU, and the CPU starts executing the configure_streams process of the second shooting mode to configure the platform session, pipeline and node of the second shooting mode.

[0134] S622: After the configure_streams process of the second shooting mode ends, the kernel layer sends a third feedback result to the hardware abstraction layer.

[0135] In this step, the third feedback result is used to indicate that the configure_streams process of the second shooting mode has ended.

[0136] S623: The kernel layer sends the image data to the hardware abstraction layer.

[0137] During the configure_streams process, after the camera sensor node is created, the hardware abstraction layer sends hardware initialization instructions to the kernel layer. After receiving the hardware initialization instructions, the kernel layer begins initializing the camera sensor. After hardware initialization is complete, the camera sensor begins collecting image data and returns it to the hardware abstraction layer through the kernel layer.

[0138] S624: The hardware abstraction layer sends the third feedback result to the application framework layer.

[0139] S625: The application framework layer sends the third feedback result to the camera application.

[0140] S626: The camera application sends a start instruction to the application framework layer. The start instruction is used to request to obtain image data.

[0141] In this step, the image data is image data collected by a camera sensor as described in S623 .

[0142] S627, the application framework layer sends a repeating instruction to the hardware abstraction layer. The repeating instruction is used to instruct the hardware abstraction layer to return image data frame by frame and indicate the storage space for the image data.

[0143] S628: The hardware abstraction layer sends the image data to the application framework layer.

[0144] In this step, the hardware abstraction layer copies each frame of image data to the storage space for transmission.

[0145] S629: The application framework layer sends the image data to the camera application.

[0146] In the description of the above method 600, because the close process and the open process of the camera application are not coupled when switching shooting modes, the open thread of the hardware abstraction layer can be called to execute the open process of the second shooting mode when executing the close process of the first shooting mode. In addition, there is idle time between the end of the open process of the second shooting mode and the start of the configure_streams process of the second shooting mode. Usually, the duration of this idle time can meet the duration required to execute the close process of the first shooting mode. In this way, the terminal device can make full use of the device hardware resources (CPU and memory) and fully dispatch the idle CPU to process the asynchronous close thread through software parallel processing, which will not bring additional cost burden to the terminal device and effectively improve the speed of mode switching.

[0147] In summary, another mode switching method as shown in FIG7 is introduced below in combination with the interaction process within the terminal device described in FIG6 and the scenario shown in FIG8 .

[0148] Figure 7 is a schematic flow chart of another mode switching method 700 provided in an embodiment of the present application. The steps of method 700 can be executed by a terminal device. In this embodiment of the present application, a mobile phone is used as an example to introduce the terminal device. Method 700 includes S701 to S703, and the specific steps are as follows:

[0149] S701, in response to an operation of opening a camera application, displaying a first interface of the camera application, where the first interface is an interface of a photographing mode.

[0150] See the schematic diagram of the mode switching interface shown in Figure 8. The first interface displayed after the user opens the camera application of the terminal device can refer to the A interface in Figure 8.

[0151] S702 , in response to an operation of switching the shooting mode to the multi-lens recording mode at a first time point, displaying a second interface of the camera application at a second time point, where the second interface is an interface of the multi-lens recording mode.

[0152] At the second time point, the second interface displayed by the terminal device may refer to interface B in FIG8 .

[0153] 6 , in response to the operation of switching the shooting mode to the multi-lens recording mode at the first time point, the terminal device may execute S601 to S630 , and the second interface in this step may be understood as the preview interface in S630 .

[0154] Between the first time point and the second time point, the first time period and the second time period overlap. The first time period is the time period for closing the photo mode based on the closing thread, and the second time period is the time period for starting the multi-camera recording mode based on the starting thread. It should be understood that the closing thread here refers to the second close thread mentioned above, that is, the asynchronous closing thread. Since the close process of the photo mode is implemented based on the second close thread, during the process of the second close thread executing the close process of the photo mode, since the open thread is also executing the open process of the multi-camera recording mode at the same time, the time period for closing the photo mode based on the closing thread overlaps with the time period for starting the multi-camera recording mode based on the starting thread.

[0155] S703 , in response to the operation of switching the shooting mode to the photographing mode at the third time point, at a fourth time point, displaying a third interface of the camera application, where the third interface is an interface of the photographing mode.

[0156] At the fourth time point, the third interface displayed by the terminal device may refer to interface C in FIG8 .

[0157] With reference to FIG6 , after responding to the operation of switching the shooting mode to the photo mode, the terminal device first executes S601 to S603. In S603, when determining whether the conditions for creating an asynchronous close thread are met, since the multi-camera recording mode does not support the creation of asynchronous close threads, that is, the determination result for the condition "whether the currently applied shooting mode supports asynchronous close threads" is negative, the terminal device can implement the serial method described in FIG4 . Specifically, the terminal device does not create an asynchronous close thread to carry out the close process of the multi-camera recording mode. Instead, it calls the first close thread established in the hardware abstraction layer to first execute the close process of the multi-camera recording mode. After the close process of the multi-camera recording mode completes, it then executes the open process of the photo mode. After the open process of the photo mode completes, it then executes the configure_streams process of the photo mode. Therefore, between the third and fourth time points, the third time period is the time period during which the multi-camera recording mode is closed by the closing thread, and the fourth time period is the time period during which the shooting mode is activated by the activation thread. The closing thread here refers to the first close thread.

[0158] It should be noted that for the multi-camera recording mode, since multi-camera recording requires opening the rear camera first and then the front camera, the two cameras work independently and are also closed independently when closed. The terminal device cannot maintain two asynchronous close threads to work at the same time, that is, it is impossible to close the multi-camera recording by creating an asynchronous close thread. Therefore, between the third time point and the fourth time point, the time period when the photo mode is closed based on the closing thread and the time period when the multi-camera recording mode is started based on the starting thread do not overlap.

[0159] Typically, when a terminal device experiences an anomaly or when testing the stability of the terminal device's camera application, the camera application will quickly switch back and forth between one shooting mode and another. Another mode switching method is described below in conjunction with FIG8 .

[0160] Figure 9 is a schematic flow chart of another mode switching method 900 provided in an embodiment of the present application. The steps of method 900 can be performed by a terminal device. In this embodiment of the present application, a mobile phone is used as an example to introduce the terminal device. The steps of method 900 can be performed after S703. Method 900 includes S901 and S902, and the specific steps are as follows:

[0161] S901, switching the shooting mode to the video recording mode at the fifth time point;

[0162] S902: Before configuring resources for the video recording mode, switch the shooting mode to the photo taking mode at a sixth time point.

[0163] Between the fifth time point and the sixth time point, the fifth time period is a time period for shutting down the video recording mode based on the shutting down thread, and the sixth time period is a time period for shutting down the photo taking mode based on the starting up thread.

[0164] It should be noted that the time intervals between the fourth and fifth time points are very short, as are the time intervals between the fifth and sixth time points. This can be understood as the terminal device rapidly switching from photo mode to video mode, and then rapidly switching from video mode to photo mode. During this rapid and frequent switching process, the terminal device immediately executes the close process for video mode after the open process for video mode completes, without executing the configure_streams process for video mode. Consequently, camera service resources are not allocated for video mode. Subsequently, when quickly switching from video mode to photo mode, the terminal device does not need to release camera service resources for video mode. This speeds up the close process for video mode and allows it to complete in a very short time. Therefore, in this scenario, the phone does not create an asynchronous close thread to handle the close process for video mode.

[0165] An embodiment of the present application provides a terminal device, which may be a first terminal device, a second terminal device, or a third terminal device. The terminal device includes: a processor and a memory; the memory stores computer-executable instructions; and the processor executes the computer-executable instructions stored in the memory, so that the terminal device performs the above method.

[0166] The present embodiment provides a chip. The chip includes a processor configured to invoke a computer program stored in a memory to execute the technical solution of the above embodiment. The implementation principles and technical effects are similar to those of the above-mentioned related embodiments and will not be further described here.

[0167] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the above-mentioned method is implemented. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the functions can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.

[0168] In one possible implementation, a computer-readable medium may include random access memory (RAM), read-only memory (ROM), compact disc read-only memory (CD-ROM) or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium designed to carry or store the desired program code in the form of instructions or data structures and accessible by a computer. Furthermore, any connection is appropriately referred to as a computer-readable medium. For example, if software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technologies such as infrared, radio and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave are included in the definition of medium. Disk and disc, as used herein, include optical discs, laser discs, optical discs, digital versatile discs (DVDs), floppy disks and Blu-ray discs, where disks typically reproduce data magnetically, while optical discs reproduce data optically using lasers. Combinations of the above should also be included within the scope of computer-readable media.

[0169] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the above method.

[0170] The present application embodiment is described with reference to the flow chart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application.It should be understood that each flow process and / or box in the flow chart and / or block diagram and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program instructions.These computer program instructions can be provided to the processing unit of general-purpose computer, special-purpose computer, embedded processing machine or other programmable device to produce a machine, so that the instruction executed by the processing unit of computer or other programmable data processing device produces the device for realizing the function specified in one flow chart flow or multiple flows and / or one block or multiple blocks of block diagram.

[0171] The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of this application in detail. It should be understood that the above are only specific implementation methods of this application and are not intended to limit the scope of protection of this application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of this application should be included in the scope of protection of this application.

Claims

1. A mode switching method, characterized in that: include: In response to an operation of opening a camera application, displaying a first interface of the camera application, wherein the first interface is an interface of a photographing mode; In response to an operation of switching the shooting mode to the multi-lens video recording mode at a first time point, displaying a second interface of the camera application at a second time point, where the second interface is an interface of the multi-lens video recording mode; Between the first time point and the second time point, the first time period and the second time period overlap; The first time period is a time period for closing the photographing mode based on the closing thread, and the second time period is a time period for starting the multi-lens video recording mode based on the starting thread; In response to the operation of switching the shooting mode to the photographing mode at a third time point, at a fourth time point, displaying a third interface of the camera application, the third interface being an interface of the photographing mode; Between the third time point and the fourth time point, the third time period and the fourth time period do not overlap; The third time period is a time period for closing the multi-lens video recording mode based on the closing thread, and the fourth time period is a time period for starting the shooting mode based on the starting thread.

2. The method according to claim 1, characterized in that After, in response to the operation of switching the shooting mode to the photographing mode at the third time point, displaying the third interface of the camera application at a fourth time point, the method further includes: At a fifth time point, the shooting mode is switched to the video recording mode; Before configuring resources for the video recording mode, switching the shooting mode to the photo taking mode at a sixth time point; There is no overlap between the fifth time point and the sixth time point; the fifth time period is a time period for shutting down the video recording mode based on the shutting down thread, and the sixth time period is a time period for starting the photo taking mode based on the starting thread.

3. The method according to claim 1, characterized in that After the operation of switching the shooting mode to the multi-lens video recording mode in response to the first time point, the method further includes: Creating the shutdown thread; The camera mode is closed based on the closing thread.

4. The method according to claim 3, characterized in that The step of creating the closing thread comprises: When the preset conditions are met, the closing thread is created; The preset conditions include: the application package name indicated by the first preconfiguration parameter includes the application package name of the camera application, the shooting mode indicated by the second preconfiguration parameter does not include the photo mode, the last closed thread at the current moment is in an idle state, and the CHI module has been initialized; The first preconfiguration parameter is used to indicate the application package name that can support the creation of the shutdown thread, and the second preconfiguration parameter is used to indicate the shooting mode that does not support the creation of the shutdown thread.

5. The method according to claim 4, characterized in that In the case where the preset condition is met, after creating the closing thread, the method further includes: Starting the multi-lens video recording mode based on a startup thread; After the multi-camera recording mode is started, if the shutdown thread is completed, start the configuration flow thread to configure resources for the multi-camera recording mode; At the second time point, displaying the second interface of the camera application includes: After the configuration stream thread is completed, at the second time point, a second interface of the camera application is displayed.

6. The method according to claim 5, characterized in that After the multi-camera recording mode is started, the method further includes: Obtaining the thread status of the closed thread; Based on the thread status of the shutdown thread, it is determined whether the shutdown thread is completed.

7. The method according to claim 6, characterized in that The determining whether the closing thread is completed based on the thread state of the closing thread includes: If the thread state of the closing thread is a terminated state, determining that the closing thread is completed; If the thread state of the shutdown thread is not a terminated state, it is determined that the shutdown thread is not completed.

8. A terminal device, characterized in that: include: processor and memory, wherein The memory is used to store computer programs; The processor is configured to call and execute the computer program so that the terminal device executes the method according to any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed on a computer, causes the computer to execute the method according to any one of claims 1 to 7.

10. A computer program product, characterized in that The invention comprises a computer program which, when being executed, causes a computer to execute the method according to any one of claims 1 to 7.