Camera control method, electronic device, chip system and readable storage medium

By issuing instructions through the desktop application in the electronic device to trigger the camera application to start the camera, the problem of the camera preview interface being stuck in scenes interrupted by motion effects is solved, and the camera can be restored to normal operation.

CN118885098BActive Publication Date: 2025-01-24HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411299356.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2025-01-24
Estimated Expiration
2044-09-18

AI Technical Summary

Technical Problem

During the process of electronic devices returning to the desktop interface, the user clicks the application icon of the camera application again to trigger the restart of the camera application, which can easily cause the camera preview interface to be stuck.

Method used

The corresponding instructions are sent under the desktop application to trigger the camera application to start the camera instead of relying on the life cycle of the camera application to avoid the camera cannot be restored due to the life cycle problem.

Benefits of technology

It effectively solves the problem of the camera preview interface getting stuck in scenes interrupted by motion effects, ensuring that the camera can resume work normally.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885098B_ABST
    Figure CN118885098B_ABST
Patent Text Reader

Abstract

The present application discloses a method for controlling a camera, an electronic device, a chip system, and a readable storage medium, and belongs to the field of terminal technology. The method includes: displaying a first interface of a camera application; after receiving a first operation, controlling the camera to turn off according to a first instruction of a desktop application through the camera application, and the first operation is used to trigger a return to a second interface of the desktop application; playing a first transition effect, and the first transition effect is a transition effect from the first interface to the second interface; in the process of playing the first transition effect, after receiving a second operation on the camera application, controlling the camera to turn on according to a second instruction of the desktop application through the camera application, and the second operation is used to trigger a return to the first interface. The present application sends corresponding instructions to the camera application according to different gestures through the desktop application to control the camera to turn off and start, so as to avoid the camera being unable to resume work in the scene where the animation is interrupted, thereby avoiding the camera preview interface from being stuck.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a camera control method, an electronic device, a chip system and a readable storage medium. Background Art

[0002] When the camera application is running, the user can trigger the electronic device to return to the desktop interface through a swipe up gesture. For example, when an upward swipe from the bottom of the screen is detected, the electronic device returns to the desktop interface in response to the user's operation.

[0003] When returning to the desktop interface, the electronic device plays a transition animation from the camera preview interface of the camera application back to the desktop interface. During the transition animation, the camera is generally turned off in advance to reduce desktop frame loss.

[0004] However, if the user clicks the application icon of the camera application again during the playing of the transition animation effect to trigger the electronic device to restart the camera application, it is easy to cause the camera preview interface to get stuck. Summary of the invention

[0005] The present application provides a camera control method, electronic device, chip system and readable storage medium, which can solve the problem that the camera preview interface is prone to freezing in the related technology. The technical solution is as follows:

[0006] In a first aspect, a method for controlling a camera is provided, which is applied to an electronic device, and the method comprises:

[0007] Display the first interface of the camera application; after receiving the first operation, control the camera to turn off according to the first instruction of the desktop application through the camera application, and the first operation is used to trigger returning to the second interface of the desktop application; play the first transition animation effect, and the first transition animation effect is a transition animation effect from the first interface to the second interface; during the playing of the first transition animation effect, after receiving the second operation on the camera application, control the camera to turn on according to the second instruction of the desktop application through the camera application, and the second operation is used to trigger returning to the first interface.

[0008] As an example, the first operation is an operation of sliding upward from the bottom of the screen. The first operation includes a down event, a move event, and an up event.

[0009] As an example, the second operation is a click operation on the application icon of the camera application.

[0010] As an example, the first instruction is an activity notify with TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START, which may also be referred to as activity notify1.

[0011] As an example, the second instruction is an activity notify with TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT, which may also be referred to as activity notify2.

[0012] In this way, the camera startup is no longer triggered by the life cycle of the camera application. Instead, the desktop application sends corresponding instructions to trigger the camera application to start the camera. This avoids the camera being unable to resume work due to reliance on the life cycle of the camera application to trigger the camera startup, thereby solving the problem of the camera preview interface being stuck in the scene interrupted by the animation.

[0013] As an example of the present application, after receiving the first operation, the camera is controlled to be turned off through the camera application according to the first instruction of the desktop application, including: after receiving the first operation, if it is determined through the desktop application that the user usage scenario is not the first scenario, then in response to the first operation, the camera is controlled to be turned off through the camera application according to the first instruction of the desktop application, wherein the first scene is a scene that continuously interrupts the playback of the first transition animation effect.

[0014] As an example, the first scene is called the animation interruption scene, that is, during the playing of the first transition animation, the user triggers the second operation on the camera application, causing the electronic device to stop playing the first transition animation, play the second transition animation, and restart the camera.

[0015] In this way, by determining whether the user usage scenario is the first scenario, triggering a continuous process of stopping the camera flow and resuming the camera work is avoided.

[0016] As an example of the present application, during the playing of the first transition animation effect, after receiving the second operation on the camera application, the camera is controlled to turn on according to the second instruction of the desktop application through the camera application, including: during the playing of the first transition animation effect, after receiving the second operation on the camera application, when it is determined through the desktop application that the camera is turned off, in response to the second operation, the camera is controlled to turn on according to the second instruction of the desktop application through the camera application.

[0017] If the camera is being used, that is, the shutdown is not complete, restarting the camera may cause exceptions or errors. Therefore, the camera application can check whether the camera has been shut down before restarting the camera. Only when the shutdown is complete will the open Camera logic be executed. This ensures that the camera is in an available state before restarting the camera, so that the camera can be started effectively and the camera startup exceptions or errors can be avoided as much as possible.

[0018] As an example of the present application, the method also includes: after receiving the first operation, querying camera status indication information; when the camera status indication information is the first indication information, determining that the user usage scenario is not the first scenario.

[0019] Exemplarily, the camera status indication information is CameraStatus. The first indication information is reset.

[0020] In this way, by setting the camera status indication information, before turning off the camera, it is determined whether it is a continuous camera stop and resume camera working scene according to the camera status indication information, thereby avoiding frequent triggering of the camera stop and resume camera process.

[0021] As an example of the present application, the method also includes: after receiving the first operation, modifying the camera status indication information to second indication information, and the second indication information is used to indicate that the camera is in an off state.

[0022] As an example, the second indication information is closed.

[0023] In this way, after receiving the first operation, the camera status indication information is modified to the second indication information, so that the camera can be started normally later.

[0024] As an example of the present application, the method also includes: after receiving the second operation, modifying the camera status indication information to third indication information, and the third indication information is used to indicate that the camera is in an on state.

[0025] As an example, the third indication information is open.

[0026] In this way, after receiving the second operation, the camera status indication information is modified to the third indication information. In the scenario where the animation is continuously interrupted, that is, the user has been performing fast gesture operations, since CameraStatus is still Open rather than Reset, the continuous camera stop flow and camera recovery process will not be triggered.

[0027] As an example of the present application, the method further includes: when the first interface completely covers the second interface, the camera status indication information is modified to the first indication information through the desktop application, so as to facilitate the subsequent normal triggering of the camera stop flow and camera resume work process.

[0028] As an example of the present application, an electronic device includes a system service. When a first interface completely covers a second interface, the camera status indication information is modified to the first indication information through a desktop application, including: when the first interface completely covers the second interface, sending a first method to the desktop application through the system service, the first method being a life cycle method called when the second interface is not visible; after receiving the first method, the desktop application modifies the camera status indication information to the first indication information.

[0029] As an example, the first method is the onStop() method.

[0030] In this way, by calling the first method, the desktop application is informed that the camera preview interface of the camera application has been fully displayed, thereby modifying the camera status indication information to the first indication information, so that the process of stopping the camera flow and resuming the camera work can be triggered normally next time.

[0031] As an example of the present application, after receiving the first operation, the camera is controlled to be turned off according to the first instruction of the desktop application through the camera application, including: after receiving the first operation, the desktop application sends an activity notification message carrying a first identifier to the camera application, and the first instruction is an activity notification message carrying the first identifier; the camera application controls the camera to be turned off according to the first identifier.

[0032] As an example, the first identifier is ACTIVITY_NOTIFIER_GESTURE_ANIM_START.

[0033] In this way, after receiving the first operation, by sending an activity notification message with the first identifier to trigger the camera application to control the camera to turn off in advance, that is, to turn off the camera before playing the first transition animation effect, the GPU load can be reduced, thereby reducing the problem of frame loss in the desktop interface.

[0034] As an example of the present application, during the playing of the first transition animation effect, after receiving the second operation on the camera application, the camera is controlled to turn on according to the second instruction of the desktop application through the camera application, including: during the playing of the first transition animation effect, after receiving the second operation, the desktop application sends an activity notification message carrying a second identifier to the camera application, and the second instruction is an activity notification message carrying the second identifier; the camera application controls the camera to turn on according to the second identifier.

[0035] As an example, the second identifier is ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT.

[0036] In this way, after receiving the second operation, an activity notification message with the second identifier is sent to trigger the camera application to control the camera to turn on, so that the camera resumes working and avoids the phenomenon that the camera preview interface is stuck.

[0037] In a second aspect, an electronic device is provided, comprising: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions so that the electronic device executes a method as described in any one of the first aspects.

[0038] In a third aspect, a chip system is provided, which is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes a method as described in any one of the first aspects.

[0039] According to a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes instructions, and when the instructions are executed on an electronic device, the electronic device executes the method as described in any one of the first aspects.

[0040] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the camera control method described in the first aspect.

[0041] The technical effects obtained by the above-mentioned second, third, fourth and fifth aspects are similar to the technical effects obtained by the corresponding technical means in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 is a schematic diagram showing a camera preview interface being stuck according to an exemplary embodiment;

[0043] Figure 2 is a flowchart of a method for controlling a camera according to an exemplary embodiment;

[0044] Figure 3 is a schematic diagram of the architecture of a software system of an electronic device according to an exemplary embodiment;

[0045] Figure 4 is a timing diagram of controlling a camera according to an exemplary embodiment;

[0046] Figure 5 is a flowchart of a method for controlling a camera according to another exemplary embodiment;

[0047] Figure 6 is a schematic diagram of a process of controlling camera shutdown according to an exemplary embodiment;

[0048] Figure 7 is a schematic diagram of a process of controlling camera startup according to an exemplary embodiment;

[0049] Figure 8 The diagram is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0050] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0051] It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, the words "first" and "second" are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not limit them to be different.

[0052] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0053] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0054] For ease of understanding, before introducing the method for controlling a camera provided in an embodiment of the present application, the nouns or terms involved in the embodiment of the present application are first introduced.

[0055] Activity: is an important part of Android applications, which represents a single user interface in the application. The life cycle of activity includes creation, start, resume, pause, stop and destruction. Developers can manage the state and behavior of activity by overriding the corresponding life cycle methods (such as onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy(), etc.).

[0056] onCreate() is called when the activity is first created and can be used to initialize the interface and data.

[0057] OnStart() is called when the activity becomes visible, indicating that the activity has or will soon be visible.

[0058] onResume() is called when the activity is ready to interact with the user. It is called by the system when the activity is restored from a stopped state (such as after the user switches to another application) to a running state, indicating that the activity becomes visible and regains focus. For example, when returning to the camera preview interface of the camera application from the desktop interface, the system calls the camera application's onResume(). onResume() can be used to restart the user interface update and resume operations related to user interaction.

[0059] onPause(), when an activity enters the paused state, the system calls this method. Exemplarily, the calling time is when the electronic device leaves the current activity, such as when the user presses the home button or the current activity is covered by another activity, onPause() will be called. For example, when returning to the desktop interface from the camera preview interface of the camera application, the system calls onPause() of the camera application. onPause() can usually be used to pause some operations of the activity, such as stopping music playback, video playback, etc. It is mainly used to process the logic when the activity is paused, such as saving status, releasing resources, etc. onPause() and onResume() usually appear in pairs.

[0060] OnStop() is called when the activity is no longer visible to release resources such as network connections and sensors.

[0061] OnDestroy() is called when the activity is about to be destroyed. It is used to clean up resources, such as stopping threads.

[0062] When the electronic device displays the camera preview interface (which may be referred to as the first interface) of the camera application, if a user's swipe-up gesture is received, such as the user swiping up from the bottom of the screen, then in response to the swipe-up gesture, the electronic device switches to the desktop interface (which may be referred to as the second interface) of the desktop application and starts playing the first transition animation effect. The first transition animation effect is a transition animation effect from the camera preview interface of the camera application to the desktop interface. Exemplarily, the last frame of the first transition animation effect is the restored desktop interface. During the playing of the first transition animation effect, since the camera is still in the on state, that is, the camera still captures images, the camera generates a large amount of data when capturing images. These data need to be processed and rendered by the graphics processing unit (GPU), which results in a high GPU load. When the GPU load is high, it may not be able to complete the rendering task of the desktop interface within the specified time (e.g., one Vsync cycle), which may easily cause the desktop interface to drop frames or freeze during the process of returning to the desktop interface.

[0063] To this end, in some embodiments, a camera stop streaming solution is provided. During the process of displaying the camera preview interface of the camera application, when a swipe up gesture is detected, the desktop application notifies the camera application in advance to control the camera to turn off, thereby reducing the GPU load in the process of returning to the desktop interface. This helps to ensure that the rendering work of each frame of the desktop interface can be completed in a timely manner, thereby reducing desktop frame loss or freezes.

[0064] In some embodiments, a new animation interruption feature is added to the desktop of the electronic device. When the user quickly clicks on the application icon of the camera application while the electronic device is playing the first transition animation, the electronic device responds to the user's click on the application icon of the camera application and redisplays the camera preview interface of the camera application. This scenario can be called an animation interruption scenario. In the process of redisplaying the camera preview interface of the camera application, the electronic device will stop playing the first transition animation, start the second transition animation, and start playing the second transition animation. The second transition animation is a transition animation that returns to the camera preview interface of the camera application. The electronic device playing the second transition animation can be understood as a reverse execution of the first transition animation. Exemplarily, the last frame of the second transition animation is the camera preview interface of the camera application. This makes the response more responsive and the animation effect better.

[0065] However, in the animation interruption scenario, the camera may be unable to resume working due to the camera stop flow solution, causing the camera preview interface to freeze.

[0066] Cause Analysis:

[0067] In the camera stop streaming solution, when the user's swipe up gesture is detected, the desktop application will notify the camera application in advance to control the camera to turn off and start playing the first transition animation. When the first transition animation ends, the onPause() of the camera application is triggered. Through onPause(), some logic when the activity of the camera application is paused can be processed, such as saving status, releasing resources, etc. After the first transition animation ends, that is, after returning to the desktop interface, when the user clicks the application icon of the camera application again, the electronic device will trigger the onResume() of the camera application. During the execution of onResume(), the camera application will call the logic of opening the camera to resume the camera.

[0068] However, in the animation interruption scenario, if the first transition animation is interrupted, that is, the user clicks on the camera application icon during the playback of the first transition animation, then because the camera application has returned to the camera application, the life cycle of the camera application will not change, that is, the camera application is still in the Resume state. At this time, the electronic device determines that the activity in the current Resume state is the same as the activity to be paused (Pause), so the scheduleTransaction() method used to convert the life cycle of the camera application will not be triggered, and thus the OnPause() of the camera application will not be triggered, and further, the OnResume() of the camera application will not be triggered. Because the camera application calls the logic of opening the camera during the execution of OnResume(), if OnResume() is not executed, the logic of opening the camera will not be called, that is, the camera will not be restarted, so the camera cannot resume working, causing the camera preview interface to freeze. For example, see Figure 1 In the motion interruption scenario, after returning from the desktop interface to the camera preview interface of the camera application, the camera preview interface S1 is stuck, that is, the screen content in the camera preview interface S1 does not change during the movement of the electronic device; or when the user clicks any camera mode control in area 1 of the camera preview interface (such as clicking control 10), the camera preview interface S1 does not switch.

[0069] To this end, the embodiment of the present application provides a method for controlling the camera. For the dynamic interruption scenario, the electronic device no longer relies on the life cycle of the camera application to trigger the camera to start up. Instead, the desktop application sends a corresponding instruction to trigger the camera application to start up the camera, thereby avoiding the camera being unable to resume work due to relying on the life cycle of the camera application to trigger the camera to start up, thereby solving the problem of the camera preview interface being stuck in the dynamic interruption scenario. Next, combined with Figure 2 The method for controlling a camera provided in an embodiment of the present application is introduced.

[0070] See also Figure 2 The method for controlling a camera provided in the embodiment of the present application may mainly include the following steps:

[0071] S201: The camera application is started.

[0072] In an exemplary application scenario, the electronic device displays a desktop interface, which includes an application icon of a camera application. When a user wants to use the camera of the electronic device to take a photo, the user can click the application icon of the camera application. In response to the user's click operation on the application icon of the camera application, the camera application is started.

[0073] Of course, the above description is based on the example of a user clicking on the application icon of the camera application to trigger the electronic device to start the camera application. In another example, if the electronic device supports voice control, the user can also control the camera application to start by voice, for example, the user can issue a voice control command of "open the camera application" to the electronic device, and accordingly, the electronic device controls the camera application to start.

[0074] It is not difficult to understand that after the camera application is started, the camera is controlled to turn on and the camera preview interface of the camera application is displayed, so that the user can trigger the electronic device to shoot through the camera based on the camera preview interface of the camera application.

[0075] S202: The camera application registers a Notify listener.

[0076] After the camera application is started, in addition to controlling the camera to open and displaying the camera preview interface of the camera application, a Notify listener is also registered. The Notify listener is used to monitor the activity notification messages sent by the desktop application, so as to control the camera to close or open according to the activity notification messages.

[0077] Exemplarily, the activity notification message is activity notify.

[0078] As an example, an activity notification message may carry a tag (TAG). When the carried tag is a different identifier, the activity notification message is used to instruct the camera application to perform different operations on the camera. That is, for the camera application, the camera can be controlled to be turned off or on according to the tag carried in the activity notification message sent by the desktop application.

[0079] In one example, when the tag carried in the activity notification message is a first identifier, the activity notification message is used to instruct the camera application to control the camera to turn off. When the tag carried in the activity notification message is a second identifier, the activity notification message is used to instruct the camera application to control the camera to turn on.

[0080] Exemplarily, the first identifier is: ACTIVITY_NOTIFIER_GESTURE_ANIM_START; the second identifier is ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT.

[0081] As an example, during the process of registering the Notify listener, the camera application creates a Notify listener and registers a monitoring object in the Notify listener, where the monitoring object is a TAG including a first identifier and a second identifier.

[0082] For example, the camera application may create a Notify listener by creating a class, for example, the Notify listener may be created by using the newMyHwActivityNotifier method.

[0083] Exemplarily, the camera application registers monitoring of the first identifier through ActivityMangerEx.registerHwActivityNotifier(mActivityNotifier, ACTIVITY_NOTIFIER_GESTURE_ANIM_START) and registers monitoring of the second identifier through ActivityMangerEx.registerHwActivityNotifier(ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT).

[0084] As an example, the camera application may register the Notify listener in a callback manner, that is, the Notify listener may be a callback. During registration, the camera application registers the callback, thereby implementing the registration of the Notify listener.

[0085] S203: During the process of displaying the camera preview interface of the camera application, the desktop application receives a swipe-up gesture, where the swipe-up gesture is an operation of triggering a return to the desktop interface.

[0086] In one example, the swipe-up gesture may be an operation of swiping upward from the bottom of the screen.

[0087] The swipe up gesture usually includes a start event (down), a move event (move), and an end event (up). The start event is triggered when the user starts touching the screen, marking the starting point of the gesture. The move event is triggered when the user's finger moves on the screen, used to track the trajectory of the finger's movement. The end event is triggered when the user's finger leaves the screen, marking the end of the gesture.

[0088] When the user wants the electronic device to return to the desktop interface, a swipe-up gesture can be triggered, and accordingly, the desktop application receives the swipe-up gesture.

[0089] S204: The desktop application sends an activity notification message (activity Notify) 1 to the camera application. ActivityNotify1 carries a TAG, and TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START.

[0090] When receiving the swipe up gesture, the electronic device switches from the camera preview interface of the camera application to the desktop interface. In addition, the desktop application sends an activity Notify with TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START to the camera application to instruct the camera application to control the camera to turn off through the activity Notify. For ease of understanding and description, the activity Notify with TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START is referred to as activity Notify1 below.

[0091] After instructing the camera application to turn off the camera, the desktop application controls the first transition animation to start playing. The first transition animation is a transition animation that switches from the camera preview interface of the camera application to the desktop interface. That is, after the desktop application sends activity Notify1 to the camera application, it controls the first transition animation to start playing.

[0092] As an example of this application, the desktop application first sends activity Notify1 to the camera application, and then controls the first transition animation to start playing, so as to notify the camera application in advance to turn off the camera, thereby reducing the GPU load during the return to the desktop interface, thereby reducing the desktop frame loss problem. After testing, it is known that the frame loss rate can be reduced by about 60%.

[0093] As an example and not a limitation, as described in the embodiments of the present application, the desktop application controlling the start of the first transition animation effect may mean that the desktop application triggers the system's animation framework to start playing the first transition animation effect, and the functions of the animation framework include defining animation effects, managing the animation effect life cycle, supporting scene switching, etc.

[0094] S205: The camera application monitors the activity Notify1 sent by the desktop application through the Notify listener.

[0095] After the desktop application sends activity Notify1 to the camera application, the callback of the Notify listener pre-registered by the camera application is triggered, so that the camera application listens to activityNotify1 through the callback.

[0096] S206: The camera application controls the camera to be turned off according to the TAG in activity Notify1.

[0097] As mentioned above, when the TAG is different, activity Notify is used to instruct the camera application to perform different operations. Since the camera application has registered the monitoring of ACTIVITY_NOTIFIER_GESTURE_ANIM_START in the Notify listener, when the desktop application sends activity Notify1 to the camera application, the camera application can determine through the Notify listener that TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START in the monitored activity Notify1, thereby determining that the camera needs to be turned off. In this case, the camera application executes the logic of turning off the camera, that is, executes the closecamera logic to control the camera to turn off, thereby reducing the GPU load.

[0098] S207: During the process of returning to the desktop interface, the desktop application receives a click operation of the user on the application icon of the camera application.

[0099] As mentioned above, during the process of returning to the desktop interface, the desktop application controls the playback of the first transition animation effect. As a possible example, during the playback of the first transition animation effect, that is, the playback of the first transition animation effect has not yet ended, the user may quickly click on the application icon of the camera application. In this case, this operation of the user will interrupt the playback of the first transition animation effect, that is, the desktop application stops controlling the playback of the first transition animation effect.

[0100] S208: The desktop application sends an activity notification message (activity Notify) 2 to the camera application. ActivityNotify2 carries a TAG, and TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT.

[0101] When receiving a user click operation on the application icon of the camera application, the electronic device switches from the current display interface to the camera preview interface of the camera application. In addition, the desktop application can send an activity Notify with TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT to the camera application, so as to instruct the camera application to control the camera to turn on, that is, to reopen the camera. For ease of understanding and description, the activity Notify with TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT is hereinafter referred to as activityNotify2.

[0102] After instructing the camera application to open the camera, the desktop application controls the second transition animation to start playing. It can be understood that the first transition animation is executed in reverse. The second transition animation is the transition animation that switches to the camera preview interface of the camera application. That is, after the desktop application sends activity Notify2 to the camera application, it controls the second transition animation to start playing.

[0103] Similarly, the desktop application controlling the second transition animation effect to start playing may mean that the desktop application triggers the system's animation framework to start playing the second transition animation effect.

[0104] As an example of the present application, the desktop application first sends activity Notify2 to the camera application, and then controls the second transition animation to start playing, so as to notify the camera application to turn on the camera in advance, so that the camera can resume working, and avoid the problem of the camera preview interface being stuck when returning to the camera application.

[0105] S209: The camera application monitors activity Notify2 sent by the desktop application through the Notify listener.

[0106] After the desktop application sends activity Notify2, the callback of the Notify listener pre-registered by the camera application is triggered. In this way, the camera application listens to activity Notify2 through the callback.

[0107] S210: The camera application controls the camera to turn on according to the TAG in activity Notify2.

[0108] As mentioned above, when the TAG is different, activity Notify is used to instruct the camera application to perform different operations. Since the camera application has registered the monitoring of ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT in the Notify listener, when the desktop application sends activity Notify2 to the camera application, the camera application can determine through the Notify listener that TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT in the monitored activity Notify2, thereby determining that the camera needs to be turned on. In this case, the camera application executes the logic of turning on the camera, that is, executes the open camera logic, to control the camera to turn on and resume the camera.

[0109] It is worth mentioning that the desktop application sends activity Notify with different TAGs to the camera application according to different gesture operations. The camera application receives activity Notify with different TAGs sent by the desktop application by registering Notify listeners for different TAGs in advance, and controls the camera to be turned off or on according to the received activity Notify, so as to reduce desktop frame loss and solve the problem of camera preview interface freezing in some embodiments due to premature camera closure and inability to resume work in the animation interruption scene.

[0110] The electronic device involved in the embodiments of the present application may be a mobile phone, a tablet computer, a laptop computer, a computer or other device. The electronic device is configured or connected with a camera, and a camera application is installed in the electronic device. The electronic device can support dynamic interruption scenes. The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a microservice architecture, or a cloud architecture. The embodiments of the present application take the Android system with a layered architecture as an example to exemplify the software system of the electronic device.

[0111] See also Figure 3 , Figure 3 It is a block diagram of a software system of an electronic device provided in an embodiment of the present application. The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer (application layer, App layer), the application framework layer (application framework layer, FWK layer), the system layer, the hardware abstraction layer (hardware abstraction layer, HAL) and the kernel layer (kernel kayer).

[0112] The application layer can include a series of application packages. Figure 3 As shown, the application package may include a desktop application (launcher) and a camera application. In addition, the application package also includes applications such as gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message (not shown in the figure), etc.

[0113] Applications in the application layer can be used to interact directly with users. These applications can be system built-in applications or non-system level applications. These applications can have icons and application interfaces, or have application interfaces without icons, or have neither icons nor application interfaces.

[0114] Among them, the desktop application is a core component in the Android operating system, which is responsible for displaying application icons, widgets, and providing an interface for users to interact with the device.

[0115] As an example, the desktop application includes a laucherAnimation module, and the desktop application performs the operations involved in the embodiments of the present application through the laucherAnimation module.

[0116] The camera application can provide a camera preview interface, allowing users to trigger the electronic device to take photos, record videos, etc. based on the camera preview interface.

[0117] As an example, the camera application includes but is not limited to a first module, a second module, a third module and a fourth module. The camera application can implement the operations performed by the camera application in the embodiments of the present application through interaction between the first module, the second module, the third module and the fourth module.

[0118] Exemplarily, the first module is defined as CameraApi2Module, the second module is defined as obtainExitBlurImage, the third module is defined as CameraController, and the fourth module is defined as DeviceFactory.

[0119] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 3 As shown, the application framework layer may include an input module (Input) and a system service (systemserver).

[0120] The input module can be used to process input events through the event pipeline, including swipe up, key press, touch, mouse movement, etc. It converts the signals generated by physical input devices into input events that the system can recognize.

[0121] System services are responsible for starting and managing the core services of the Android system, including but not limited to activity manager service (AMS) and activity task manager service (ATMS).

[0122] AMS is mainly used to uniformly schedule various applications in the application layer. As an example, in the Android system, when an application wants to start a new activity, it usually reports to AMS. AMS internally records all the activities of all applications. Since AMS has records of all activities, AMS can schedule and manage these activities and automatically kill background activities according to the status of the activities and system memory.

[0123] ATMS is mainly responsible for managing the tasks and stacks of activities. It handles the startup, switching and closing of activities, as well as the maintenance of task stacks. ATMS provides applications with an interface for managing activities through the Binder mechanism, allowing applications to request to start or close activities. ATMS works together with AMS to ensure the smooth operation of applications and user experience in the Android system.

[0124] In addition, the application framework layer may also include a window manager, a content provider, a view system, etc. (not shown in the figure).

[0125] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0126] Content providers are used to store and retrieve data and make it accessible to applications. These data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0127] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build the display interface of an application, and the display interface can be composed of one or more views.

[0128] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0129] The system library can include multiple functional modules, such as: surface manager, media library, 3D graphics processing library (such as: OpenGL ES), 2D graphics engine (such as: SGL), etc.

[0130] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0131] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc.

[0132] The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0133] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing.

[0134] The hardware abstraction layer is located between the framework layer and the kernel layer. Its purpose is to abstract the hardware. The hardware abstraction layer hides the hardware interface details of a specific platform and provides a virtual hardware platform for the software system, making it hardware-independent and portable on multiple platforms. As an example, the hardware abstraction layer provides a camera control module that can be used to control the camera.

[0135] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver. These drivers can drive the display screen, front / rear camera, audio player, sensor, etc. Sensors include but are not limited to touch sensors, and accordingly, sensor drivers include touch sensor drivers.

[0136] exist Figure 3 Based on the embodiment shown, next Figure 4 This article introduces the method and process of controlling the camera.

[0137] When the camera preview interface of the camera application is displayed, if the user triggers the swipe up gesture, the input module first receives the start event (down) of the swipe up gesture, for example, see Figure 4 At time t1, the input module receives the start event (down) of the slide-up gesture, and the input module reports the start event (down) to the desktop application. Exemplarily, the input module can call the handleEvent interface of the desktop application to report the start event (down) to the desktop application through the handleEvent interface.

[0138] After receiving the start event (down), the desktop application notifies the system service.

[0139] The system service calls the onStart() method of the desktop application to pull up the desktop interface, making the desktop interface visible.

[0140] When the user's swipe up gesture ends, that is, when the user's finger leaves the screen, the input module receives the end event (up) of the swipe up gesture. Figure 4 At time t2, the user's swipe up gesture ends, and the input module receives the end event (up) of the swipe up gesture. The input module reports the end event (up) to the desktop application. Exemplarily, the input module can call the handleEvent interface of the desktop application to report the end event (up) to the desktop application through the handleEvent interface.

[0141] After receiving the end event (up), the desktop application sends activity Notify1 to the system service, where TAG = ACTIVITY_NOTIFIER_GESTURE_ANIM_START, and activityNotify1 is sent to the camera application through the system service.

[0142] The camera application determines that the camera needs to be turned off based on TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START, so it executes the close Camera logic to turn off the camera.

[0143] See also Figure 4 , between time t1 and time t2, the desktop application maintains the hand tracking stage, and the camera application still displays the camera preview interface until after time t2, when the camera application executes the close Camera logic.

[0144] After time t2, the desktop application controls the first transition animation to start playing.

[0145] During the playing of the first transition animation, the user clicks the application icon of the camera application, for example, the user clicks the application icon of the camera application at time t3. Correspondingly, the input module receives the corresponding camera Click event, and the input module reports the camera Click event to the desktop application. Exemplarily, the input module can call the handleEvent interface of the desktop application to report the camera Click event to the desktop application through the handleEvent interface.

[0146] After receiving the camera Click event, the desktop application sends activity Notify2 to the system service. The TAG in activityNotify2 is ACTIVITY_NOTIFIER_GESTURE_ANIM_START_INTERRUPT, and the activity Notify2 is sent to the camera application through the system service.

[0147] The camera application determines that the camera needs to be opened according to TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START_INTERRUPT. At this time, the camera application waits for the camera to be closed and then executes the open Camera logic to open the camera so that the camera resumes working. After the camera is opened, the camera application displays the camera preview interface.

[0148] It is worth noting that if the camera is being used, that is, the shutdown is not complete, restarting the camera at this time may cause exceptions or errors. Therefore, the camera application can check whether the camera has been shut down before restarting the camera. Only when the shutdown is complete will the open Camera logic be executed. This ensures that the camera is in an available state before restarting the camera, so that the camera can be started effectively and the camera startup exceptions or errors can be avoided as much as possible.

[0149] See also Figure 5 , Figure 5 is a flowchart of a method for controlling a camera according to an exemplary embodiment. The embodiment of the present application introduces the detailed implementation of controlling the camera. As an example but not a limitation, the embodiment of the present application uses the method to Figure 3 The electronic device shown is implemented by the interaction of multiple modules as an example. Specifically, it may include part or all of the following contents:

[0150] S501: The AMS calls the onResume() method of the camera application to resume displaying the camera preview interface of the camera application.

[0151] The onResume() method of the camera application is called in the following two possible situations:

[0152] In one possible case, before AMS calls the onResume() method, the camera application is not started, and the user clicks the application icon of the camera application from the desktop interface, or clicks a button from another application. This button is used to trigger the start of the camera application. In this case, AMS will call the onResume() method of the camera application.

[0153] In another possible situation, before AMS calls the onResume() method, the camera application is running in the background, and the user triggers the camera application to return to the foreground. For example, the user selects the camera application from the recent application list, triggering the camera application to return to the foreground. In this case, AMS will also call the onResume() method of the camera application.

[0154] When the onResume() method of the camera application is called, it indicates that the camera application is ready to interact with the user, that is, the camera application displays the camera preview interface and obtains the focus, and the user can perform shooting operations based on the camera preview interface.

[0155] S502: The camera application registers a Notify listener with ATMS.

[0156] As an example, after the camera application is started, a Notify listener may be registered through the first module to listen to the activity notify sent by the desktop application side through the Notify listener.

[0157] As an example but not limitation, the Notify listener can be a callback, and the camera application registers the callback in ATMS through the first module, thereby realizing the registration of the Notify listener. In this way, when ATMS subsequently receives the activity notify from the desktop application side, it can transmit the received activity notify to the camera application by calling the callback, so that the camera application listens to the activitynotify through the Notify listener.

[0158] S503: After the desktop interface is no longer visible, the AMS calls the onStop() method of the desktop application.

[0159] After the desktop interface is no longer visible, AMS usually triggers the desktop application to release resources. To this end, AMS calls the onResume() method of the camera application and then calls the onStop() method of the desktop application to release resources.

[0160] S504: The desktop application sets CameraStatus to reset.

[0161] As an example, CameraStatus is camera status indication information.

[0162] As an example of the present application, CameraStatus has three states: reset, closed, and open.

[0163] When CameraStatus is reset, the flag can trigger the process of stopping the camera flow, that is, it can trigger the process of turning off the camera.

[0164] When CameraStatus is closed, the flag can trigger the process of turning on the camera, that is, the camera can be controlled to resume working.

[0165] When CameraStatus is open, the flag cannot trigger the process of stopping the camera flow, that is, it cannot trigger the process of closing the camera.

[0166] The reason for setting CameraStatus is that in one possible scenario, the user continuously performs quick gesture operations, such as: triggering a swipe-up gesture to return to the desktop interface - clicking the application icon of the camera application - triggering a swipe-up gesture to return to the desktop interface. At this time, the user will continuously interrupt the first transition effect, that is, triggering a swipe-up gesture to return to the camera application during the playback of the first transition effect, and when returning to the camera application but not completely returning to the camera preview interface, triggering a swipe-up gesture to allow the desktop application to control the playback of the first transition effect, and so on. In this case, continuous camera stop and recovery of the camera workflow will be triggered, which may easily lead to a timing conflict of activity notify. To this end, the desktop application can record the current status of the camera through the CameraStatus flag bit, and then determine whether to trigger the camera stop and resume the camera workflow based on the recorded CameraStatus.

[0167] As an example of the present application, after completely returning to the camera preview interface of the camera application, that is, the camera preview interface of the camera application completely covers the desktop interface, and the desktop interface is not visible, if a swipe up gesture is detected, the camera stop flow process can be triggered. Therefore, after completely returning to the camera preview interface of the camera application, that is, when AMS calls the onStop() method of the desktop application, the desktop application sets CameraStatus to reset, that is, restores the CameraStatus status bit, so that the camera stop flow process can be triggered normally when a swipe up gesture is detected later. Exemplarily, it can be restored by CameraStatus==CAMERA_RESET.

[0168] Of course, if the camera preview interface of the camera application is not completely returned, that is, AMS does not call the onStop() method of the desktop application, the desktop application does not set CameraStatus to reset.

[0169] It should be noted that after the desktop application is started, CameraStatus can be set to a default value. For example, after the computer is turned on, the desktop application is started and CameraStatus is set to reset, which is not limited in the present embodiment.

[0170] S505: When the camera preview interface is displayed, the input module receives a start event (down) of a swipe up gesture.

[0171] When the camera preview interface is displayed, when the user wants to return to the desktop interface, he can swipe up from the bottom of the screen to trigger the swipe-up gesture. In the process of triggering the swipe-up gesture, when the user's finger begins to touch the screen, the start event (down) of the swipe-up gesture is triggered. Accordingly, the touch sensor driver reports the start event (down) of the swipe-up gesture to the input module, so that the input module receives the start event (down) of the swipe-up gesture.

[0172] S506: The input module reports a start event (down) to the desktop application.

[0173] Exemplarily, the input module reports the start event (down) to the desktop application by calling the handleEvent interface of the desktop application.

[0174] S507: The desktop application reports a start event (down) to the AMS.

[0175] Because AMS is responsible for managing the life cycle of each activity, the desktop application reports the start event (down) of the swipe-up gesture to AMS so that AMS can call the corresponding life cycle method of the activity according to the start event (down) and record the corresponding life cycle of the activity.

[0176] S508: AMS launches the desktop application.

[0177] AMS calls the onStart() method of the desktop application to launch the desktop application so that the desktop interface is visible.

[0178] S509: The input module receives an end event (up) of the upward sliding gesture.

[0179] In the process of triggering the swipe-up gesture, when the user's finger leaves the screen, the end event (up) of the swipe-up gesture is triggered. Accordingly, the touch sensor driver reports the end event (up) to the input module, so that the input module receives the end event (up) of the swipe-up gesture.

[0180] S510: The input module reports an end event (up) to the desktop application.

[0181] Exemplarily, the input module reports the end event (up) to the desktop application by calling the handleEvent interface of the desktop application.

[0182] S511: When the desktop application determines that CameraStatus is reset, the desktop application updates CameraStatus to closed.

[0183] When the desktop application queries CameraStatus and finds that it is reset, it determines that the process of closing the camera can be triggered. At this time, the desktop application updates CameraStatus to the closed state so that the process of opening the camera can be triggered normally in the subsequent animation interruption scene, and performs the following S512 operation.

[0184] S512: The desktop application sends activity notify1 to ATMS.

[0185] TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START in activity notify1.

[0186] As mentioned above, when CameraStatus is reset, the flag can trigger the process of turning off the camera. Therefore, the desktop application sends activitynotify (i.e., activity notify1) with TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START to ATMS, so that activity notify1 is transmitted to the camera application through ATMS, thereby instructing the camera application to turn off the camera.

[0187] As an example of the present application, the desktop application can send an activity notify with TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START to ATMS by calling the JlogEx.jLogEvent method with the ANIM_START parameter.

[0188] As an example, the core pseudo code of the desktop application sending activity notify1 to ATMS is:

[0189] if (CameraStatus == CAMERA_RESET) { / / Currently the camera can be normally triggered to stop streaming

[0190] JlogEx.jLogEvent("GESTURE", "ANIM_START");

[0191] / / Record CameraStatus

[0192] CameraStatus = CAMERA_CLOSED;

[0193] }

[0194] It should be noted that there is no strict order between the desktop application updating CameraStatus to closed and sending activity notify1 to the desktop application ATMS. As an example, these two operations can be implemented in one thread, which can ensure a certain timing and avoid the situation where CameraStatus is not updated to closed after the desktop application sends activitynotify1 to ATMS.

[0195] S513: ATMS sends activity notify1 to the camera application through callback.

[0196] As mentioned above, the camera application registers a callback with ATMS through the first module when registering the Notify listener. Therefore, when ATMS receives activity notify1 sent by the desktop application, it can transmit activity notify1 to the camera application by calling the callback.

[0197] S514: The camera application monitors activity notify1 through the Notify listener.

[0198] The first module in the camera application listens to activity notify1 through the Notify listener.

[0199] S515: The camera application controls the camera to be turned off based on the TAG in activity notify1.

[0200] TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START in activity notify1. Based on this, the camera application determines that the camera needs to be turned off, so the camera application triggers the process of turning off the camera.

[0201] As an example, see Figure 6 The specific implementation of the camera application controlling the camera to turn off can include the following steps:

[0202] A1: The first module calls the closeCameraAsync() method of the second module to issue a camera closing instruction.

[0203] When the first module monitors TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_START_START in activity notify1 through the Notify listener, it determines that the desktop application instructs to turn off the camera. In this case, the first module calls the closeCameraAsync() method in the second module to issue a camera closing instruction, thereby instructing to turn off the camera.

[0204] As an example, when the first module determines that the camera needs to be closed based on the TAG in the monitored activity notify1, before calling the closeCameraAsync() method of the second module, it can determine whether the camera application has completed image storage. After determining that the image storage is completed, the first module calls the closeCameraAsync() method of the second module to instruct the camera to be closed. In this way, it is avoided that the camera application executes the logic of closing the camera before the image is stored when the user triggers the camera application to take a picture before closing the camera, thereby avoiding the problem of image storage failure.

[0205] As an example, when the first module determines that the camera needs to be closed based on the monitored activity notify1, before calling the closeCameraAsync() method of the second module, it determines whether the camera application has completed storage. After determining that the image storage is completed, the first module can also obtain the last frame preview image before the camera is closed, and then blur the last frame preview image to obtain a blurred image. The first module stores the blurred image so that the blurred image can be displayed first after the camera application is restarted later, avoiding the display of a black image due to the failure to generate a preview image in time after the camera application is restarted, thereby improving the user experience.

[0206] Exemplarily, the first module may call the obtainCurrentFrameForBlur() method in the second module to obtain the last preview image frame. The first module may determine whether the last preview image frame is obtained according to the boolean abtained flag in the obtainCurrentFrameForBlur() method. For example, if the last preview image frame is obtained, the boolean abtained flag is true, and if the last preview image frame is not obtained, the boolean abtained flag is false. If the last preview image frame is obtained, the first module may blur the obtained preview image by calling the setObtainCurrentFrameForBlurStatus() method in the second module to obtain a blurred image.

[0207] A2: The second module calls the closeCameraAsync() method of the third module to issue a camera closing instruction.

[0208] A3: The third module calls the closeCameraAsync() method of the fourth module to issue a camera closing instruction.

[0209] A4: The fourth module sets the conditional lock to the closed state.

[0210] In order to avoid abnormal camera startup caused by restarting the camera during the process of closing the camera, the fourth module can set the conditional lock to a closed state before controlling the camera to close, indicating that the camera shutdown is not complete and the camera cannot be restarted at this time.

[0211] As an example, the fourth module may set the condition lock to a close state by calling the waitCloseCameraDoneCondition.close() method.

[0212] A5: The fourth module calls the cleanUpSurfaceList() method of the cameraServiceInternal class of the camera application to clear the surface list.

[0213] Surface is a camera-related component that can be used to manage the display and processing of the camera's preview image and other image data.

[0214] In the Android system, each surface occupies system resources, including memory and GPU resources. If the camera application no longer needs these resources, it should usually release them in time to avoid unnecessary resource occupation and potential memory leaks. Therefore, when closing the camera, the fourth module clears the surface list related to the camera.

[0215] A6: The fourth module closes the session channel.

[0216] When using the camera, the camera application usually establishes a session channel with the HAL layer, such as establishing a session channel with the camera control module of the HAL layer, to control the camera to capture images through the session channel. When closing the camera, the fourth module closes the session channel to release channel resources and discards the relevant instructions to be issued for instructing to capture images.

[0217] Exemplarily, the fourth module may close the session channel and discard related instructions by calling the destroyCaptureSession() method of the realDevice class of the camera application.

[0218] A7: The fourth module calls the closeCamera() method of the realDevice class of the camera application to close the camera.

[0219] A8: After the camera is closed, the fourth module sets the conditional lock to the open state.

[0220] This indicates that the camera shutdown has been completed. In this way, when the camera is started again later, the process of starting the camera can be determined based on this state of the conditional lock.

[0221] S516: The desktop application controls the first transition animation effect to start playing.

[0222] After the desktop application sends activity notify1 to ATMS to instruct the camera application to turn off the camera, it can control the first transition animation to start playing.

[0223] S517: During the playing of the first transition animation effect, the input module receives a camera click event.

[0224] As an example, during the playing of the first transition animation, that is, the playing of the first transition animation has not yet ended, the user quickly clicks on the application icon of the camera application, that is, it is in the animation interruption scene. At this time, the touch sensor driver reports the camera click event to the input module.

[0225] S518: The input module reports the camera click event to the desktop application.

[0226] As an example, the input module may report the camera Click event to the desktop application by calling the handleEvent interface of the desktop application.

[0227] S519: When the desktop application determines that the CameraStatus is closed, the desktop application updates the CameraStatus to open.

[0228] After receiving the camera click event, the desktop application queries the value of CameraStatus. If CameraStatus is closed, it means that the process of opening the camera can be triggered. In order to avoid the timing conflict of activity notify, the desktop application updates CameraStatus to open and performs the following S520 operation.

[0229] S520: The desktop application sends activity notify2 to ATMS.

[0230] TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT in activity notify2.

[0231] As described above, when CameraStatus is closed, the flag can trigger the process of opening the camera, so the desktop application sends activity notify2 to ATMS, so that the activity notify2 is transmitted to the camera application through ATMS, thereby instructing the camera application to open the camera.

[0232] As an example, a desktop application can send an activity notify with TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT to ATMS by calling the JlogEx.jLogEvent method with the ANIM_INTERRUPT parameter.

[0233] As an example, the core pseudo code of the desktop application sending activity notify2 to ATMS is:

[0234] if (CameraStatus == CAMERA_CLOSED) { / / Currently the camera can be normally triggered to resume interruption

[0235] JlogEx.jLogEvent("GESTURE", "ANIM_INTERRUPT");

[0236] / / Record CameraStatus

[0237] CameraStatus = CAMERA_OPEN;

[0238] }

[0239] It should be noted that there is no strict order between the desktop application updating CameraStatus to open and sending activity notify2 to ATMS. In an example, these two operations are implemented by one thread to ensure a certain timing to avoid the situation where CameraStatus is not updated to open after the desktop application sends activity notify2 to ATMS.

[0240] S521: ATMS sends activity notify2 to the camera application through callback.

[0241] As described above, the camera application registers a callback with ATMS through the first module when registering the Notify listener. Therefore, when ATMS receives activity notify2 sent by the desktop application, it can transmit the activity notify2 to the camera application through the callback.

[0242] S522: The camera application monitors activity notify2 through the Notify listener.

[0243] The first module in the camera application listens to activity notify2 through the Notify listener.

[0244] S523: The camera application controls the camera to open based on the TAG in activity notify2.

[0245] TAG=ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT in ctivity notify2. Based on this, the camera application determines that the camera needs to be turned on, so the camera application triggers the process of turning on the camera.

[0246] As an example, the core pseudo code of the camera application parsing the activity notify execution operation is:

[0247] If (receive activity notify of TAG == ACTIVITY_NOTIFIER_GESTURE_ANIM_START) {

[0248] Trigger the callback logic of the Notify listener;

[0249] If (the image saving process ends) {

[0250] Get the last frame of image for blur processing;

[0251] Call the camera closing logic;

[0252] }

[0253] } else if (receive activity notify of TAG == ACTIVITY_NOTIFIER_GESTURE_ANIM_INTERRUPT) {

[0254] Trigger the callback logic of the Notify listener;

[0255] Wait for the camera to be closed;

[0256] Execute the camera opening logic;

[0257] }

[0258] As an example, see Figure 7 The specific implementation of the camera application controlling the camera to open can include the following steps:

[0259] B1: The first module calls the waitCloseCameraDone() method of the second module to request whether the camera is closed.

[0260] As mentioned above, before reopening the camera, the camera usually needs to be closed completely. To this end, the first module calls the waitCloseCameraDone() method in the second module to issue a camera status query instruction, thereby requesting to query whether the camera is closed completely.

[0261] B2: The second module calls the waitCloseCameraDone() method of the third module.

[0262] B3: The third module calls the waitCloseCameraDone() method of the fourth module.

[0263] B4: When the fourth module determines that the camera shutdown is completed according to the state of the conditional lock, it feeds back a camera shutdown completion notification to the third module.

[0264] As an example, the fourth module can call the waitCloseCameraDoneConditon.block() method to query the status of the condition lock. When the status of the condition lock is open, it means that the camera closing is completed. At this time, the fourth module feeds back the camera closing completion notification to the third module; if the status of the condition lock is close, it means that the camera closing is not complete. At this time, the fourth module can wait until the status of the condition lock becomes open, and then feed back the camera closing completion notification to the third module.

[0265] B5: The third module feeds back a notification of camera closing completion to the second module.

[0266] B6: The second module feeds back a notification of camera closing completion to the first module.

[0267] B7: The first module calls the openCamera() method of the second module to issue a camera opening instruction.

[0268] When receiving the notification that the camera is closed, it is determined that the camera is closed and can be reopened. Therefore, the first module calls the openCamera() method of the second module to issue a camera opening instruction.

[0269] The second module of B8 calls the openCamera() method of the third module to issue a camera opening instruction.

[0270] B9: The third module calls the openCamera() method of the fourth module to issue a camera opening instruction.

[0271] B10: The fourth module obtains the camera ID and camera feature list.

[0272] The camera ID can be used to uniquely identify a camera. By obtaining the camera ID, the camera application can determine the camera that needs to be opened.

[0273] The camera feature list usually provides the specifications supported by the camera hardware, such as supported resolution, exposure time range, flash availability, etc. Obtaining the camera feature list allows the camera application to adjust its functions and performance according to the actual capabilities of the camera. In addition, before opening the camera, the camera application may need to configure parameters according to the camera feature list, such as configuring a suitable preview size, adjusting the focal length, white balance, etc., to ensure that the camera can meet specific shooting requirements after it is opened.

[0274] B11: The fourth module calls the openCamera() method of the RealDevice class of the camera application to open the camera.

[0275] In this way, the camera can be restarted when the animation interrupts the scene.

[0276] For example, taking opening a camera in normal photo mode as an example, the internal logic of executing the openCamera() method of the RealDevice class is to obtain the camera feature list, initialize the callback for monitoring the camera status (such as initializing the stateCallBack callback), and then call the openCamera method of CameraRetryOpener to open the camera through the openCamera method of the Android native CameraManaer.

[0277] CameraManager is a system service in the Android system that manages all cameras on electronic devices. It provides an interface for camera applications to interact with the camera. Through CameraManager, camera applications can implement functions such as camera preview, photo taking, and video recording.

[0278] RealDevice is a class used to encapsulate the openCamera method of CameraRetryOpener, and CameraRetryOpener is a class used to encapsulate the openCamera method of CameraManager.

[0279] Optionally, after controlling the camera to turn on, the camera application displays a blurred image through the first module.

[0280] S524: The camera application controls the playback of the second transition animation effect.

[0281] After the desktop application sends activity notify2 to ATMS to instruct the camera application to open the camera, it can control the second transition animation to start playing.

[0282] It is worth noting that in the scenario where the animation is continuously interrupted, that is, the user has been performing quick gesture operations, at this time, since it has not completely returned to the camera preview interface of the camera application, AMS will not call onResume() of the camera application, nor will it call onStop() of the desktop application. Therefore, CameraStatus is still Open instead of Reset, and therefore will not trigger the continuous camera stop and resume process.

[0283] In an embodiment of the present application, a camera preview interface of a camera application is displayed. Afterwards, if a swipe-up gesture to return to the desktop is received, the camera is controlled to turn off through the camera application according to a first instruction from the desktop application. The first transition animation is played, and the first transition animation is a transition animation from the camera preview interface of the camera application to the desktop interface of the desktop application. During the playing of the first transition animation, after receiving a restart operation on the camera application, the camera is controlled to turn on through the camera application according to a second instruction from the desktop application. In this way, the camera startup is no longer triggered by the life cycle of the camera application. Instead, the desktop application sends a corresponding instruction to trigger the camera application to start the camera, thereby avoiding the inability to resume work due to reliance on the life cycle of the camera application to trigger the camera startup, thereby solving the problem of the camera preview interface being stuck in the scene interrupted by the animation.

[0284] Figure 8 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 8 The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (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 screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, 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, etc.

[0285] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0286] 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 processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0287] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0288] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0289] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0290] The charging management module 140 is used to receive charging input from a charger. The charger can be a wireless charger or a wired charger. The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193 and the wireless communication module 160.

[0291] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0292] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0293] The display screen 194 is used to display images, videos, etc. The 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 or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is an integer greater than 1.

[0294] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0295] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is an integer greater than 1.

[0296] 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 electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0297] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created by the electronic device 100 during use (such as audio data, a phone book, etc.), 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.

[0298] The electronic device 100 can implement audio functions, such as music playback, recording, etc., through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D and the application processor.

[0299] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor 180K can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0300] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.

[0301] An embodiment of the present application also provides a chip system, which is applied to an electronic device. The chip system includes one or more processors, and the one or more processors are used to call computer instructions to enable the electronic device to execute the methods described in the above embodiments.

[0302] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (such as: coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (such as: infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital versatile disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)).

[0303] The above are optional embodiments provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the technical scope disclosed in the present application shall be included in the protection scope of the present application.

Claims

1. A method for controlling a camera, characterized in that: Applied to electronic equipment, the method comprises: Display the first interface of the camera application; After receiving the first operation, controlling the camera to turn off according to the first instruction of the desktop application through the camera application, wherein the first operation is used to trigger returning to the second interface of the desktop application; Playing a first transition animation effect, where the first transition animation effect is a transition animation effect for switching from the first interface to the second interface; During the playing of the first transition animation effect, after receiving a second operation on the camera application, the camera is controlled to turn on according to a second instruction of the desktop application through the camera application, and the second operation is used to trigger a return to the first interface.

2. The method according to claim 1, characterized in that After receiving the first operation, controlling the camera to close according to the first instruction of the desktop application through the camera application includes: After receiving the first operation, if it is determined through the desktop application that the user usage scenario is not the first scenario, then in response to the first operation, the camera is controlled to be turned off through the camera application according to the first instruction of the desktop application, wherein the first scene is a scene that continuously interrupts the playback of the first transition animation effect.

3. The method according to claim 1 or 2, characterized in that The method of receiving a second operation on the camera application during the playing of the first transition animation effect and controlling the camera to turn on according to the second instruction of the desktop application through the camera application includes: During the playing of the first transition animation effect, after receiving the second operation on the camera application, when it is determined through the desktop application that the camera is turned off, in response to the second operation, the camera application is controlled to turn on according to the second instruction of the desktop application.

4. The method according to claim 2, characterized in that The method further comprises: After receiving the first operation, querying camera status indication information; When the camera status indication information is the first indication information, it is determined that the user usage scenario is not the first scenario.

5. The method according to claim 4, characterized in that The method further comprises: After receiving the first operation, the camera status indication information is modified into second indication information, where the second indication information is used to indicate that the camera is in an off state.

6. The method according to claim 4 or 5, characterized in that The method further comprises: After receiving the second operation, the camera status indication information is modified into third indication information, where the third indication information is used to indicate that the camera is in an on state.

7. The method according to claim 6, characterized in that The method further comprises: In a case where the first interface completely covers the second interface, the camera status indication information is modified to the first indication information through the desktop application.

8. The method according to claim 7, characterized in that The electronic device includes a system service; In the case where the first interface completely covers the second interface, modifying the camera status indication information to the first indication information by the desktop application includes: In a case where the first interface completely covers the second interface, sending a first method to the desktop application through the system service, where the first method is a life cycle method called when the second interface is not visible; After receiving the first method, the desktop application modifies the camera status indication information into the first indication information.

9. The method according to any one of claims 1, 2, 4 or 5, characterized in that After receiving the first operation, controlling the camera to close according to the first instruction of the desktop application through the camera application includes: After receiving the first operation, the desktop application sends an activity notification message carrying a first identifier to the camera application, where the first instruction is an activity notification message carrying the first identifier; The camera application controls the camera to be turned off according to the first identifier.

10. The method according to any one of claims 1, 2, 4 or 5, characterized in that The method of receiving a second operation on the camera application during the playing of the first transition animation effect and controlling the camera to turn on according to the second instruction of the desktop application through the camera application includes: During the playing of the first transition animation effect, after receiving the second operation, the desktop application sends an activity notification message carrying a second identifier to the camera application, where the second instruction is an activity notification message carrying the second identifier; The camera application controls the camera to turn on according to the second identifier.

11. An electronic device, characterized in that: The electronic device includes: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method described in any one of claims 1-10.

12. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method described in any one of claims 1-10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Upper sliding effect exception handling method and electronic equipment

    CN116991274A

  • Application program exit control method and device

    CN117724772A