Data storage method and related device

By saving the context of writing handwriting in the canvas on an electronic device, the problem that traditional text input methods cannot meet the needs of fast recording and data loss is solved, and the effect of quickly saving and stable storage of handwritten data is achieved.

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

Patent Information

Application Number
CN202410897214.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2025-07-01
Estimated Expiration
2044-07-04

AI Technical Summary

Technical Problem

Traditional text input methods cannot meet user needs in scenarios such as quickly recording sketches and handwritten notes, and the user's handwritten notes are prone to data loss.

Method used

Provides a data storage method to quickly save handwritten data to avoid data loss by displaying the context of writing handwriting in the canvas on an electronic device. The specific implementation method includes saving the context of the writing handwriting in the first canvas when the display mode changes, and converting it into picture storage if necessary.

Benefits of technology

It realizes the rapid saving of handwritten data, reducing the possibility of data loss and improving user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916120B_ABST
    Figure CN118916120B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a data storage method and related device, relating to the field of terminal technologies. In this method, when a change in the display mode is triggered, the electronic device can save the context of the writing strokes in the canvas. Since the storage process of the context of the writing strokes in the canvas is relatively fast, it is conducive to quickly saving the handwritten data. In this way, the electronic device can obtain the interface after the change in the display mode based on the saved context of the writing strokes in the canvas, which is conducive to avoiding data loss.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of terminals, and in particular, to a data storage method and related devices. Background Art

[0002] With the popularization of electronic devices and the progress of technology, users' demand for recording notes on electronic devices is increasing day by day. However, traditional text input methods may not meet users' needs in some scenarios, such as when quickly recording sketches, handwritten notes, etc. Of course, users also hope that these handwritten notes can be easily saved, shared, and viewed.

[0003] In some implementations, the content of handwritten notes by users sometimes has data loss problems, affecting the user experience. Summary of the Invention

[0004] Embodiments of this application provide a data storage method and related devices, which can save the context of the writing strokes on the canvas. Since the storage process of the context of the writing strokes on the canvas is fast, it is beneficial to quickly save handwritten data and avoid data loss.

[0005] In a first aspect, an embodiment of this application proposes a data storage method applied to an electronic device. The method includes: at a first moment, a first interface is displayed. The first interface includes a first canvas, which is used to receive a user's writing operation and present writing strokes. The first canvas is in a writable state, and the first interface is in a first display mode; at a second moment, a first operation triggering a change in the display mode is received; at a third moment, a second interface is displayed. The second interface also includes the first canvas, and the first canvas is still in a writable state. The writing strokes in the first canvas are the same as those at the first moment. The second interface is displayed based on the first operation, and the second interface is in a second display mode, which is different from the first display mode. Among them, the second moment is after the first moment, and the third moment is after the second moment. Between the second moment and the third moment, the first canvas in the first interface is not saved as a picture, and the first canvas in the second interface is obtained based on the context of the writing strokes in the first canvas saved after the second moment.

[0006] Exemplarily, the first interface may be Figure 1 the interface shown in Figure 1 , the first canvas may be Figure 8 the handwriting area 101 in Figure 8The handwriting area 801 in [the second interface], the display mode of the second interface can be, for example, a dark mode, or it can also be called a night mode. The embodiments of the present application do not limit this.

[0007] It should be understood that Figure 8 the handwriting area 801 in [the second interface] is restored from the data saved by Figure 1 the handwriting area 101 in [the first interface], so Figure 8 the handwriting area 801 in [the second interface] and Figure 1 the handwriting area 101 in [the first interface] can be understood as the same canvas, or, Figure 8 the handwriting area 801 in [the second interface] can be understood as being re-created based on Figure 1 the data saved by the handwriting area 101 in [the first interface], and is the same canvas as Figure 1 the handwriting area 101 in [the first interface]. The present application does not limit this.

[0008] In the embodiments of the present application, the first canvas in the second interface is obtained based on the context of the writing strokes in the first canvas saved after the second moment. Since the storage process of the context of the writing strokes in the first canvas is relatively fast, which is conducive to quickly saving the handwriting data, the electronic device can be restored based on the context of the writing strokes in the first canvas during the process of displaying the second interface, which is conducive to avoiding the situation of data loss.

[0009] It should also be understood that in the related art, when it is necessary to store the data related to the first canvas, the implementation method is to store the view data of the first canvas as a picture, and each reporting point in the view data of the first canvas needs to be stored in the bitmap format. Since there is reporting point data without user handwriting in the view data of the first canvas, its storage process is relatively slow. While in the embodiments of the present application, the context of the writing strokes in the first canvas stored on the one hand only contains the data with user writing strokes, and on the other hand does not require complex format conversion and is faster, so it is conducive to quickly saving the user's handwriting data and is conducive to avoiding the situation of handwriting data loss.

[0010] A so-called reporting point can be understood as a unit for the electronic device to record the user's writing strokes, which is used to define a region on the canvas. It can be a single pixel as a unit, or multiple pixels as a unit, or a unit defined by other measurement units. It can be similar to the "point position" mentioned in the above method 600, and will not be explained repeatedly.

[0011] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: at a fourth moment after the third moment, in response to a second operation on the second interface, displaying a third interface, where the third interface includes a first picture, and the content presented by the first picture is the same as the writing strokes in the first canvas of the second interface, and the third interface is also in the second display mode, and the second operation is used to exit the writable state of the first canvas in the second interface.

[0012] Exemplarily, the second operation may be a click operation by the user on a control 802 in the interface as Figure 8 shown. In response to this operation, the third interface displayed by the electronic device may be as Figure 9 shown, and the first picture may be as Figure 9 shown as 901 in it. The content presented by 901 is the same as the writing strokes in 801, except that 901 is in the form of a picture and is not writable. From Figures 8 to 9 , the display mode of the electronic device may not change.

[0013] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: at a fifth moment, displaying a fourth interface, where the fourth interface includes a second canvas, and the second canvas is used to receive the user's writing operation and present writing strokes, and the second canvas is in a writable state, and the fourth interface is in a third display mode; at a sixth moment, receiving a third operation that triggers a change in the display mode; at a seventh moment, displaying a fifth interface, where the fifth interface includes a second picture, and the content presented by the second picture is the same as the writing strokes in the second canvas, and the fifth interface is displayed based on the third operation, and the fifth interface is in a fourth display mode, and the fourth display mode is different from the third display mode; where the sixth moment is after the fifth moment, the seventh moment is after the sixth moment, and between the sixth moment and the seventh moment, the electronic device successfully saves the view data of the second canvas as the second picture after saving the context of the writing strokes in the second canvas.

[0014] Exemplarily, the fourth interface may also be an interface as Figure 1 shown, the second canvas may also be Figure 1 the handwriting area 101 in it, and the fifth interface may be an interface as Figure 9 shown, and the second picture may be Figure 9 901 in it.

[0015] In the embodiment of the present application, after the electronic device saves the context of the handwriting on the second canvas, it also successfully saves the view data of the second canvas as a second picture. Since the view data of the second canvas has been successfully saved as a second picture and the picture data has good stability, when the electronic device restores the second canvas, it can also restore the second canvas in the form of the second picture. In this way, the restored fifth interface is not prone to garbled characters, which is beneficial to providing a better user experience.

[0016] In combination with the first aspect, in some implementation manners of the first aspect, the electronic device includes a first application that supports a handwriting input function. The receiving of the first operation that triggers a change in the display mode includes: the main thread receives the first operation that triggers a change in the display mode, and the main thread is the main thread for interface display in the first application; the method further includes: the main thread starts a process of destroying the main thread and pulls up a child thread based on the first operation, and the child thread is a child thread of the main thread and is used for storing data; the child thread obtains and saves the context of the handwriting on the first canvas from the main thread; the displaying of the second interface includes: when the main thread is restarted after being destroyed, the restarted main thread loads the context of the handwriting on the first canvas and displays the second interface by using the context of the handwriting on the first canvas.

[0017] Optionally, the first application may be a note application on the electronic device or any other application that supports handwriting input, and the present application does not make any limitation thereto.

[0018] It should be understood that the main thread may be the Activity of the note application, which is a visual user interface responsible for creating a screen window and placing UI components for user interaction. The child thread is pulled up by the Activity main thread and is used for storing relevant data in the Activity main thread, such as data related to handwriting. The child thread 1 mentioned in other places in the embodiment of the present application may have a similar meaning to the child thread described here.

[0019] It should also be understood that when the main thread is destroyed, the child thread pulled up by the main thread is also destroyed synchronously. For the introduction of the life cycle of the Activity main thread, reference can be made to Figure 5 the corresponding description, which will not be elaborated here.

[0020] Furthermore, the "handwritten data", "handwriting" and the like described in the embodiments of the present application all refer to the data collected by the electronic device in the case of user handwriting input, and the present application does not make specific limitations on the specific content included in this data.

[0021] In the embodiments of the present application, during the process of the main thread executing the destruction process, the child thread obtains and saves the context of the writing strokes in the first canvas from the main thread. During the process of the main thread restarting after destruction, the context of the writing strokes in the first canvas is loaded to restore the first canvas. In this way, it is beneficial to timely save the relevant data of the first canvas, reduce the possibility of the writing strokes in the first canvas being lost, and improve the user experience.

[0022] In combination with the first aspect, in some implementation manners of the first aspect, during the destruction process of the main thread, the method further includes: the child thread sets a flag bit and sets the value of the flag bit to a first value, where the first value is used to indicate that the canvas fails to be saved as a picture; the child thread obtains the size data of the first canvas from the main thread; the child thread saves a third picture with the same size as the first canvas based on the size data of the first canvas, and the third picture does not contain visual content; when the restarted main thread loads the context of the writing strokes in the first canvas, it includes: when the restarted main thread determines that the value of the flag bit is the first value, it loads the third picture and the context of the writing strokes in the first canvas; when using the context of the writing strokes in the first canvas to display the second interface, it includes: the restarted main thread determines the size of the first canvas using the third picture, and loads the writing strokes in the first canvas on a canvas with the same size as the third picture to display the second interface.

[0023] Exemplarily, the implementation process of this embodiment can be similar to the process in which the child thread 1 executes S601 - S605 and then the Activity main thread executes S608 - S610 in method 600. The specific process can refer to the description in method 600 and will not be elaborated here.

[0024] Optionally, the third picture can be the empty picture described in method 600. The meaning of the empty picture can be that it does not contain visual content, or is completely transparent, or only contains some default colors (such as white, black, or other solid colors, etc.), but the present application does not make specific limitations on this. The third picture is invisible to the user and can play the role of a placeholder in UI design.

[0025] In combination with the first aspect, in certain implementations of the first aspect, the electronic device includes a first application that supports a handwriting input function. The receiving of the third operation that triggers a change in the display mode includes: the main thread receives the third operation that triggers a change in the display mode, and the main thread is the main thread for interface display in the first application, and the main thread is the main thread for interface display in the first application; the method further includes: the main thread starts a process to destroy the main thread and launches a child thread based on the third operation, and the child thread is a child thread of the main thread and is used to store data; the child thread sets a flag bit and sets the value of the flag bit to a first value, and the first value is used to indicate that the canvas cannot be saved as a picture; the child thread obtains the view data of the second canvas from the main thread, and the view data includes the size data of the second canvas and the color data of each reported point in the second canvas; the child thread saves a fourth picture with the same size as the second canvas based on the size data of the second canvas, and the fourth picture does not contain visual content; the child thread obtains and saves the context of the handwriting on the second canvas from the main thread; when the main thread has not been destroyed yet, the child thread saves the view data as the second picture based on the size data of the second canvas and the color data of each reported point included in the view data; the child thread modifies the value of the flag bit to a second value, and the second value is used to indicate that the canvas has been successfully saved as a picture; the displaying of the fourth interface includes: when the main thread is restarted after being destroyed, the restarted main thread loads the second picture to display the fourth interface when determining that the value of the flag bit is not the first value.

[0026] Exemplarily, the implementation process of this embodiment can be similar to the process in which child thread 1 executes S601 - S607 and then the Activity main thread executes S608 - S609 - S611 in method 600. The specific process can refer to the description in method 600 and will not be elaborated here.

[0027] Optionally, the fourth picture can have a similar meaning to the above-mentioned third picture and will not be elaborated.

[0028] Optionally, the value of the flag bit (which can be denoted as flag) can be true, false, or binary numbers such as 0, 1, etc. This application does not make any limitations in this regard. Exemplarily, in the embodiments of this application, the first value can be true and the second value can be false.

[0029] It can be seen that when the running time of the child thread is sufficient, after the child thread saves the context of the writing strokes in the second canvas, it can further save the view data of the second canvas as a second picture. During the process of restarting the main thread after it is destroyed, the restarted main thread can restore the second canvas in the form of the second picture. In this way, the fifth interface restored by the electronic device is not prone to garbled characters, which is beneficial to providing a better user experience.

[0030] Under the saving order of the embodiments of the present application, at least the context of the writing strokes in the second canvas can be saved. On the premise of ensuring that the writing strokes in the second canvas are not lost, the view data of the second canvas can be further saved as a second picture. This is not only beneficial to reducing the risk of data loss but also conducive to maintaining the stability of the data, which is beneficial to providing a better user experience.

[0031] Optionally, in this case, the restarted main thread can also restore the second canvas by using the context of the writing strokes in the second canvas, so that the user can directly enter the writable state of the second canvas, simplifying the user operation.

[0032] In combination with the first aspect, in some implementation manners of the first aspect, the main thread is the main thread of the interface activity Activity.

[0033] In combination with the first aspect, in some implementation manners of the first aspect, the context of the writing strokes includes one or more of the following data for each reporting point in the writing strokes: position data, color data, or pen type data.

[0034] In combination with the first aspect, in some implementation manners of the first aspect, the context of the writing strokes is saved in the ent file format.

[0035] Second aspect, an embodiment of the present application provides a data storage device, which may be an electronic device, or a chip or a chip system within an electronic device. The data storage device may include a display unit and a processing unit. When the data storage device is an electronic device, the display unit may be a display screen. The display unit is configured to perform the display step, so that the electronic device implements a data storage method described in the first aspect or any possible implementation manner of the first aspect. When the data storage device is an electronic device, the processing unit may be a processor. The data storage device may further include a storage unit, which may be a memory. The storage unit is used to store instructions, and the processing unit executes the instructions stored in the storage unit, so that the electronic device implements a data storage method described in the first aspect or any possible implementation manner of the first aspect. When the data storage device is a chip or a chip system within an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit, so that the electronic device implements a data storage method described in the first aspect or any possible implementation manner of the first aspect. The storage unit may be a storage unit within the chip (such as registers, caches, etc.), or a storage unit outside the chip within the electronic device (such as read-only memory, random access memory, etc.).

[0036] Third aspect, an embodiment of the present application provides an electronic device, including 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, and the computer program code includes computer instructions. The one or more processors call the computer instructions to enable the electronic device to execute the method described in the first aspect or any possible implementation manner of the first aspect.

[0037] Fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes a computer program or instructions. When the computer program or instructions are run on a computer, the computer is enabled to execute the method described in the first aspect or any possible implementation manner of the first aspect.

[0038] Fifth aspect, an embodiment of the present application provides a computer program product, which includes computer program code. When the computer program code is run on a computer, the computer is enabled to execute the method described in the first aspect or any possible implementation manner of the first aspect.

[0039] Sixth aspect, the present application provides a chip or a chip system, which includes one or more processors and a communication interface. The communication interface and the one or more processors are interconnected by lines. The one or more processors are configured to run a computer program or instructions to execute the method described in the first aspect or any possible implementation manner of the first aspect. Among them, the communication interface in the chip can be an input / output interface, a pin or a circuit, etc.

[0040] In a possible implementation, the chip or the chip system described above in the present application further includes at least one memory, and instructions are stored in the at least one memory. The memory can be a storage unit inside the chip, such as a register, a cache, etc., or it can also be a storage unit of the chip (such as a read-only memory, a random access memory, etc.).

[0041] It should be understood that the second aspect to the sixth aspect of the present application correspond to the technical solutions of the first aspect of the present application. The beneficial effects obtained by each aspect and the corresponding feasible implementation manners are similar and will not be elaborated here. Description of the Drawings

[0042] Figure 1 Schematic diagram of an electronic device interface provided by an embodiment of the present application;

[0043] Figure 2 Another schematic diagram of an electronic device interface provided by an embodiment of the present application;

[0044] Figure 3 Another schematic diagram of an electronic device interface provided by an embodiment of the present application;

[0045] Figure 4 Schematic block diagram of the software structure of an electronic device provided by an embodiment of the present application;

[0046] Figure 5 Schematic diagram of the life cycle of an Activity provided by an embodiment of the present application;

[0047] Figure 6 Schematic flowchart of a data storage method provided by an embodiment of the present application;

[0048] Figure 7 Schematic diagram of the coordinates of location data provided by an embodiment of the present application;

[0049] Figure 8 Schematic diagram of an electronic device interface provided by an embodiment of the present application;

[0050] Figure 9 Another schematic diagram of an electronic device interface provided by an embodiment of the present application;

[0051] Figure 10 Schematic block diagram of the hardware structure of an electronic device provided by an embodiment of the present application;

[0052] Figure 11 Schematic block diagram of a chip structure provided by an embodiment of the present application. Detailed implementation manners

[0053] For the convenience of clearly describing the technical solutions of the embodiments of the present application, the following briefly introduces some terms and technologies involved in the embodiments of the present application:

[0054] 1. Activity: Activity (usually translated as "activity" or "interface activity") is an application component. All operations in Activity are closely related to users and is a component responsible for interacting with users. Activity provides a user interface that users can use to interact to complete a certain task. When a user opens an application, in fact, an Activity is started, and this Activity becomes the current focus and is presented to the user for interaction.

[0055] For example, in the embodiments of the present application, the note application interface displayed on the electronic device seen by the user belongs to the Activity thread included in the note application process.

[0056] 2. Terms

[0057] In the embodiments of the present application, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and roles. For example, the first chip and the second chip are only used to distinguish different chips and do not limit their sequence. Those skilled in the art can understand that terms such as "first" and "second" do not limit the quantity and execution order, and terms such as "first" and "second" do not necessarily mean different.

[0058] It should be noted that in the embodiments of the present application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design solution described as "exemplarily" or "for example" in the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, using words such as "exemplarily" or "for example" is intended to present related concepts in a specific manner.

[0059] In the embodiments of the present application, "at least one" means one or more, and "a plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after. "At least one (item)" or similar expressions refer to any combination of these items, including any combination of single item (s) or multiple items (s). For example, at least one (item) of a, b, or c can represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c can be single or multiple.

[0060] 3. Electronic device

[0061] The electronic device in the embodiments of the present application may include a handheld device with a handwriting function, a vehicle-mounted device, etc. For example, some electronic devices are: mobile phone, tablet computer, handheld computer, laptop computer, mobile internet device (MID), wearable device, virtual reality (VR) device, augmented reality (AR) device, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, cellular phone, cordless phone, session initiation protocol (SIP) phone, wireless local loop (WLL) station, personal digital assistant (PDA), handheld device with wireless communication function, computing device or other processing device connected to a wireless modem, vehicle-mounted device, wearable device, electronic device in a 5G network or an electronic device in a future evolved public land mobile network (PLMN), etc. The embodiments of the present application do not limit this.

[0062] By way of example and not limitation, in the embodiments of the present application, the electronic device may also be a wearable device. A wearable device, also known as a wearable intelligent device, is a general term for devices developed by applying wearable technologies to the intelligent design of daily wear, such as glasses, gloves, watches, clothing, shoes, etc. A wearable device is a portable device that is directly worn on the body or integrated into the user's clothes or accessories. A wearable device is not only a hardware device, but also realizes powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable intelligent devices include those with complete functions and large sizes that can achieve complete or partial functions without relying on a smart phone, such as smart watches or smart glasses, etc., and those that only focus on a certain type of application function and need to cooperate with other devices such as smart phones, such as various smart bracelets and smart jewelry for physical sign monitoring.

[0063] In addition, in the embodiments of the present application, the electronic device may also be an electronic device in an Internet of Things (IoT) system. The IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, so as to realize an intelligent network of human-machine interconnection and object-object interconnection.

[0064] The electronic device in the embodiments of the present application may also be referred to as: electronic device, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile platform, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent, or user device, etc.

[0065] With the popularization of electronic devices and the progress of technology, users' demand for taking notes on electronic devices is increasing day by day. In some scenarios, the traditional text input method may not meet the needs of users in some cases, such as when it is necessary to quickly record sketches, handwritten notes, etc.

[0066] Some electronic devices can support the function of handwritten notes. However, when there is handwritten text in the note, when the electronic device needs to refresh the display screen interface view, such as when the screen is flipped, the electronic device needs to update the view data of the electronic device before the change to the view after the change, which may cause the problem of the misalignment of the position of the handwritten text, bringing a bad user experience. Therefore, in some implementations, the electronic device converts the content in the user's handwritten area into a picture for storage. When the above-mentioned situation of refreshing the display screen interface view occurs, the position of the text in the handwritten area has been locked in the form of a picture, so as to avoid the problem of misalignment of the position that the handwritten text may occur.

[0067] Figure 1 An exemplary note application interface of an electronic device is shown, such as Figure 1 shown. This note records information related to the meeting with the theme of "Content Quality and Security Assessment Meeting", which includes the content handwritten by the user in the user area 101 and other content such as the "meeting theme" 102 entered by keyboard input or voice input in other areas. Figure 1 In it, the controls 103, 104, 105, and 106 can be the controls displayed when in the handwritten input state. Optionally, 103 can be the back control, 104 can be the forward control, 105 can be the completion control, and the control 106 can include the pen types, pen tip colors supported by the electronic device, and the keypad call-out button, etc. When the note is in the handwritten input state, the area 101 can display a dotted line boundary as shown in Figure 1 shown, but this application does not limit this.

[0068] In a possible implementation, after the user clicks the completion control 105, the controls 103, 104, 105, and 106 can be all hidden or partially hidden on the interface as shown in Figure 1 shown. The area 101 is converted from an editable canvas to a picture, and the boundary of the area 101 is a solid line boundary, such as shown in Figure 2 shown, but this application also does not limit this, and the area 101 can also have no boundary. It should be noted that in the interface shown in Figure 2 there can also be controls such as 201, 202, and 204 shown. Among them, the meanings of 201, 202, and 204 can be respectively similar to those of the controls 103, 104, and 105 shown in Figure 1 shown. However, the controls 103, 104, and 105 control the handwritten input actions, while 201, 202, and 204 control the input actions using other methods, or the input actions for the entire note page, including handwritten input and input actions using other methods. The user can end the editing operation of the entire note by clicking the control 204. Figure 2 It also includes a control 203, and the control 203 can be used to search for text or symbols in this note.

[0069] From Figure 1 the state where the area 101 in it is an editable handwritten canvas is converted to Figure 2 the state where the area 101 in it is already in the picture state, which can be because the note exits the handwritten input mode. For example, after the user clicks the control 105 shown in Figure 1 shown, the handwritten content can be converted and stored as a picture. However, the user may also be in the process of handwritten input, that is, when the handwritten content has not been converted to a picture (for example Figure 1In the case shown), when the situation of refreshing the display screen interface view is triggered, if there is a large amount of handwritten data, the process of converting it into a picture may take a long time. If this time exceeds the time required to refresh the view, it may be due to the handwritten data not being converted into a picture in time, resulting in a situation where the data in the handwritten area 101 shown in Figure 3 is lost, seriously affecting the user experience.

[0070] In view of this, the embodiments of the present application provide a data storage method and related device. When a situation where the display screen interface view needs to be refreshed occurs, the context of the valid handwritten data is stored. Since the process of storing the context of the valid handwritten data is relatively fast, the electronic device can be restored based on the context of the handwritten data during the process of restoring the handwritten canvas, which helps to avoid the situation of data loss.

[0071] It should be understood that the valid handwritten data refers to the writing strokes on the handwritten canvas. For each stroke written by the user, its writing strokes can be recorded through code, for example, recorded through the java list method. In some implementations, this record is temporary and not written into storage. In the embodiments of the present application, this record can be stored for the restoration of the handwritten canvas.

[0072] Optionally, the situations that can cause the display screen interface view to be refreshed in the present application can be: the size of the display area changes or the screen display mode changes, for example, from landscape mode to portrait mode, or from portrait mode to landscape mode, or for an electronic device with a foldable screen, its display screen is folded or unfolded; or the screen brightness changes from light mode (daytime mode) to dark mode (night mode) or from dark mode to light mode, etc. The present application does not limit this.

[0073] For the sake of convenience of description, in the following, the above situations that can cause the display screen interface view to be refreshed are collectively referred to as the change of the display mode of the electronic device, and will not be repeated for explanation later.

[0074] In the embodiments of the present application, the electronic device includes a hardware layer and a software system running on the hardware layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The software system can include any one or more computer operating systems that implement business processing through processes, for example, Linux operating system, Unix operating system, Android operating system, iOS operating system, or windows operating system, etc.

[0075] The software system of an electronic device can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of this application, taking the Android system with a layered architecture as an example, the software structure of the electronic device is illustrated exemplarily.

[0076] Figure 4 It is a block diagram of the software structure of the electronic device in the embodiments of this application.

[0077] 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, the application framework layer, the system layer, and the kernel layer.

[0078] The application layer may include a series of application program packages such as system applications and / or third-party applications. For example, the application program package may include a note application and a system user interface control center (systemUI), etc. In the embodiments of this application, the user can perform operations such as writing input by running the note application and creating notes.

[0079] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions. As Figure 4 shown, the application framework layer may include an Input Management Service (InputManagerService), a Window Management Service (WindowManagerService), a Resource Manager (ResourceManager), an Activity Management Service (ActivityManagerService), a View System (ViewSystem), a database interface, and a system file interface.

[0080] Among them, the Input Management Service can be used to manage and process user input events; the Window Management Service can be used to manage the display and layout of windows, and implement functions such as creating, displaying, hiding, moving, and resizing windows; the Resource Manager can be used to provide various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc.; the Activity Management Service can be used to manage the life cycle of applications, for example, starting, stopping, and destroying Activities in applications, and managing the processes of applications; the View System can be used to build and manage the user interface (UI) of applications.

[0081] The database interface and the system file interface are respectively used to provide APIs for the upper layer to access the database and file system of the system layer.

[0082] The system library may include multiple functional modules. For example: the input synthesis module (InputFlinger), the layer synthesis module (SurfaceFlinger), the graphics processing library (such as OpenGL), the file system, and the database (such as SQLite).

[0083] Among them, the input synthesis module can be used to process the handling and distribution of system input events; the surface synthesis module can be used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications; the graphics processing library can be used to implement three-dimensional graphics drawing, image rendering, synthesis, and layer processing, etc.; both the file system and the database can be used to store data, but their storage methods and access methods are different. In the embodiments of the present application, the original context of the valid handwritten data can be converted into an ent file and stored in the file system, and the text data formed by keyboard input, voice input, and the bitmap data converted from the handwritten data can be stored in the database, but the present application does not limit this.

[0084] The kernel layer is the layer between the hardware and the software. The kernel layer at least includes device input drivers, file drivers, and display drivers, etc.

[0085] It should be understood that in some embodiments, the layer that implements the same function may be called other names, or the layer that can implement the functions of multiple layers may be regarded as one layer, or the layer that can implement the functions of multiple layers may be divided into multiple layers. The embodiments of the present application do not limit this.

[0086] Next, in combination with the usage scenario of the note application, the working processes of the software and hardware of the electronic device will be described exemplarily.

[0087] For example, when a user clicks on the area displayed by the note application icon on the screen of an electronic device to launch the note application, the workflow of the software and hardware of the electronic device can be as follows: The touch screen hardware of the electronic device responds to the click operation, generates corresponding electrical signals (including the click time and the position on the screen), and transmits the electrical signals to the device input driver in the kernel layer. The device input driver processes the electrical signals into event instructions recognizable by the operating system and transmits them to the input composition module in the system layer. The input composition module encapsulates the events read from the hardware and transmits them to the input management service in the application layer. The input management service distributes the click event to the note application, and the note application notifies the operating system to start the application process. During the process of the operating system starting the application process, an Activity can be created through the activity management service. Until the UI of the Activity enters the running state, the UI of the Activity will be displayed on the screen, and this UI can be the note interface seen by the user. During the process of the Activity preparing the UI, the Activity interacts with the surface composition module through the window management service, receives the layers of the note application and the system, and synthesizes multiple layers together through the acceleration rendering of the surface composition module and the graphics processing library, and outputs it to the display driver to display the UI on the display screen.

[0088] Further, the user can create a note by clicking on the control for creating a new note on the note application interface. After performing a handwriting input or any other input operation, the user can obtain an interface as shown in Figure 1 or Figure 2 the figure.

[0089] It should be understood that when the display mode of the electronic device described above changes, it will cause the Activity in the note application to restart. First, the life cycle of the Activity will be introduced below.

[0090] In some implementations, the life cycle of the Activity can include a creation stage, a running stage, a pause stage, a stop stage, and a destruction stage. Applying the above-mentioned stages, the callback methods adopted in the life cycle of the Activity can be onCreate(), onResume(), onPause(), onStop(), and onDestroy() in sequence. Its life cycle process can be as shown in Figure 5 the figure.

[0091] Among them, during the application creation phase, the system can call onCreate(). onCreate() is the first callback method in the entire life cycle and is used for initializing operations of the Activity, such as setting the layout, initializing variables, etc. The running phase is one of the most important states in the Activity life cycle. It is the phase where the user can see and interact with the application. After the application enters the running state, the system can call onResume() to interact with the user, update the UI, register listeners, etc. When the application loses focus (for example, when a new Activity is launched or the screen is locked), the Activity is in the paused state, that is, the Activity no longer interacts with the user. The system can call onPause() to save the current state of the Activity, such as stopping animations, saving data, and releasing resources that are no longer needed, such as unregistering listeners. At this time, the application is still visible but cannot interact with the user. When the application is completely invisible, the system can call onStop() to release resources, such as stopping music playback and closing database connections. When the application enters the destruction phase, the system calls onDestroy() to release all resources occupied by the Activity, such as deleting temporary files and clearing caches. onDestroy() is the last callback method in the entire life cycle of the Activity.

[0092] In a possible implementation, since the running phase of the Activity is the phase where the user can see and interact with the application, the change in the display mode of the electronic device can occur in this phase. When the display mode of the electronic device changes, the main thread of the Activity starts a child thread 1 for storing handwritten data. The child thread 1 obtains the handwritten data from the temporary storage of the main thread of the Activity, and then converts the handwritten data into a picture and stores it in the database, so that during the process of the Activity life cycle ending and restarting to the running phase, the picture can be obtained from the database again and displayed in the user interface. The running processes of the child thread 1 and the main thread of the Activity can be as Figure 5 shown.

[0093] However, the researchers of this application found that if the child thread 1 cannot complete the process of converting the handwritten data into a picture before the main thread of the Activity finishes the destruction phase, then the situation described in the previous part of this article will occur Figure 1 In the interface shown, after the display mode of the electronic device changes, it is updated to Figure 3 the interface shown, and the handwritten data is lost.

[0094] Next, to address the above technical problems, in combination with Figures 6 to 8A data storage method 600 provided by an embodiment of the present application will be described in detail. This method 600 can be applied to a software architecture such as Figure 4 the electronic device shown, but the present application does not limit this.

[0095] Taking the change of the display mode of the electronic device as an example, that is, the display mode of the electronic device changes from the light mode to the dark mode, combined with Figure 4 , this process will be briefly described. In some implementations, the user clicks on the target control of the system interface control center application of the electronic device (the control for changing the display mode from the light mode to the dark mode, or from the dark mode to the light mode). The touch screen hardware of the electronic device responds to the click operation, generates a corresponding electrical signal (including the click time and the position on the screen), and transmits this electrical signal to the device input driver in the kernel layer. The device input driver processes this electrical signal into an event instruction recognizable by the operating system and transmits it to the input synthesis module in the system layer. The input synthesis module encapsulates the events read from the hardware and transmits them to the input management service in the application layer. The input management service distributes this click event to the system interface control center application. The system interface control center application notifies the view system to adjust parameters such as the screen brightness and color temperature, and restarts the Activity of the note application. During this process, the window management service transmits the updated layer of the system interface control center and the layer of the Activity to the surface synthesis module. Through the accelerated rendering of the surface synthesis module and the graphics processing library, multiple layers are synthesized together and output to the display driver, and this UI is displayed on the display screen.

[0096] When the Activity main thread receives the restart instruction from the system interface control center, it starts a child thread 1. Specifically, S601 - S607 in this method 600 can be executed by the above - mentioned child thread 1, and S608 - S611 are executed by the Activity main thread.

[0097] The method 600 may include the following steps:

[0098] S601. The child thread 1 obtains the data 1 corresponding to the handwritten canvas view from the temporary memory of the Activity main thread. The data 1 includes the size information of the handwritten canvas and the color information of each point on the handwritten canvas.

[0099] It should be understood that in the Activity layout file, the view for inputting handwritten content can usually be a custom View class that inherits from a standard view class (such as View, SurfaceView, Canvas combined with the onDraw method of View, etc.). The handwritten content input by the user on this view is converted into a data structure that can be drawn on the Canvas. The data 1 includes the data structure on the Canvas, and this application does not make any limitations on this.

[0100] It should also be understood that the data structures on the Canvas are usually used internally in the program and exist in a form suitable for graphics rendering (such as points, lines, planes, etc.) for real-time rendering and drawing.

[0101] In a possible implementation, the handwritten canvas view can establish communication and interaction with the webview through a webbridge, enabling the handwritten canvas view in the form of Java code and the webview in the form of JavaScript code to be recognized by each other, so that the handwritten canvas can be recognized and displayed by electronic devices of multiple different systems.

[0102] S602. The sub-thread 1 sets a flag bit 1 in the database and sets the value of the flag bit 1 to the target value 1.

[0103] In the embodiments of this application, the flag bit 1 is used to indicate whether the data 1 is successfully stored as a picture. Optionally, the target value 1 can be used to indicate that the data 1 fails to be stored as a picture. The target value 1 can be true. This application does not make specific limitations on the value of the flag bit.

[0104] It should be understood that the location, type, storage path, etc. of each data in the database all have a "directory" in the database. The handwritten canvas should be stored in the picture format. In the "directory", the above-mentioned data 1 should be marked as a picture and associated with the Universally Unique Identifier (UUID) of the picture. In the embodiments of this application, the flag bit 1 set by the thread 1 is associated with the UUID corresponding to the data 1. In this way, in the case where there are multiple pictures in the "directory", the picture indicated by the flag bit 1 can be uniquely determined through the UUID.

[0105] It should also be understood that the "directory" is only an image description of the mapping relationship existing for the location, type, storage path, etc. of each data in the database. This application does not make any limitations on the specific name of this mapping relationship. In some implementations, this mapping relationship file can be an html format file.

[0106] S603. The child thread 1 stores an empty image with the same size as the handwritten canvas in the database based on the size information of the handwritten canvas included in Data 1.

[0107] In some implementations, the empty image can be stored in the storage path that should store or is set to store the image converted from Data 1. In the embodiments of the present application, the attribute of the empty image can be invisible to the user.

[0108] The empty image can be understood as not including valid color information in the image, or it can be understood that each pixel in the image contains the same color information.

[0109] S604. The child thread 1 obtains Data 2 from the temporary memory of the Activity, and Data 2 is data related to the user's writing strokes.

[0110] Optionally, Data 2 may include the position data corresponding to each point in each stroke written by the user on the handwritten canvas, the pen type data corresponding to each position data, the color data corresponding to each position data, and the timestamp corresponding to each position data. A point can include one pixel or several pixels. The present application does not specifically limit the specific information included in Data 2 and the meaning of the point.

[0111] Exemplarily, as Figure 7 shown, taking the rectangular handwritten canvas as shown in Figure 7 as an example, a coordinate system can be established with the upper left vertex of the handwritten canvas area as the coordinate origin O, the upper boundary as the x-axis, and the left boundary as the y-axis. For each stroke written by the user in the handwritten canvas, the coordinates (x, y) of each point in each stroke under the coordinates shown in the figure are recorded. This coordinate information can be understood as the position data corresponding to each point in each stroke.

[0112] In some implementations, Data 2 is a file temporarily stored by the Activity. These files need to be converted into a file type that can be read and written by the disk if they are to be stored on the disk. Exemplarily, Data 2 is a java list file.

[0113] S605. The child thread 1 converts Data 2 into a file in ent format and stores it in the file system.

[0114] In the embodiments of the present application, since the empty picture does not need to record the color information of each point on the handwriting canvas, the time for Thread 1 to store the empty picture is much less than the time to convert Data 1 into a picture containing all its information. Data 2 is the context of the object class used to record the handwriting during the user's handwriting process by the Activity. The process of converting this file into a file type that can be read and written by the disk is also relatively fast. Therefore, the success rate of Thread 1 in storing the empty picture and Data 2 is relatively high, which is beneficial for the Activity main thread to provide effective data for the UI of the Activity during the restart process and is beneficial for reducing the possibility of user handwriting data loss.

[0115] Optionally, Sub-thread 1 can also execute S606 - S607.

[0116] S606: Sub-thread 1 converts Data 1 into a picture A containing all the information of Data 1 and stores it in the database.

[0117] It should be understood that the picture A can be data in bitmap format. The bitmap format can be understood as a picture storage format. The data in bitmap format in S606 contains all the information of Data 1, such as the size information of the handwriting canvas and the color information of each point on the handwriting canvas mentioned above.

[0118] S607: Sub-thread 1 sets the value of the flag bit 1 to the target value 2.

[0119] Optionally, the target value 2 can be used to indicate that Data 1 has been successfully stored as the picture A. The target value 2 can be false, but the present application does not make any limitation in this regard.

[0120] Thread 1 and the Activity main thread run in parallel. If Thread 1 can complete S606 before the destruction phase (the phase of calling the onDestroy() method) in the life cycle of the Activity main thread, it means that Data 1 has been successfully converted into a picture A containing all the information of Data 1, which also means that Data 1 can be restored in picture format when the Activity main thread resumes. In this way, Thread 1 can continue to execute S606 to set the value of the flag bit 1 to the target value 2 to indicate that when the Activity main thread resumes, Data 1 is restored to a picture A containing all the information of Data 1.

[0121] When the Activity main thread restarts to the running phase, execute the following S608 - S611.

[0122] S608: The Activity main thread loads data from the database.

[0123] S609. The main thread of the Activity determines whether the value of flag bit 1 is the target value 1. If the value of the flag bit is the target value 1, execute S609; if the value of the flag bit is not the target value 1, execute S610.

[0124] It should be understood that if the value of flag bit 1 is the target value 1, it means that thread 1 fails to execute or fails to complete the above S606 - S607, the destruction phase of the main thread of the Activity has been completed, and thread 1 has also been destroyed. Since the process of thread 1 executing the above S602 - S605 is very fast, in this case, the valid information corresponding to data 1 can be stored in a file in ent format; if the value of flag bit 1 is the target value 2, it means that thread 1 has executed the above S606 - S607 before being destroyed, and data 1 has been converted into data in bitmap format for storage.

[0125] S610. The main thread of the Activity loads an empty image from the database, loads the ent file from the file system, and restores the ent file to an editable canvas with the same size as the empty image.

[0126] It should be understood that the ent file includes the position data corresponding to all points of each stroke written by the user, the pen type data corresponding to each position data, and the color data. In some implementations, during the process of the main thread of the Activity restoring the word data, a canvas with the same size as the empty image can be created first, and then according to the position data corresponding to all points of each stroke written by the user, the pen type data corresponding to each position data, and the color data, the user's handwritten strokes are redrawn on the new canvas.

[0127] In a possible implementation manner, when the display mode changes from the light mode to the dark mode, after the electronic device executes the above S610, the display screen of the electronic device can display an interface as shown in Figure 8 It can be seen that Figure 1 The difference from Figure 8 is only the background color. After the display mode of the electronic device changes, the handwritten canvas is still in an editable state, and the user can directly write on the handwritten canvas. The method provided by the embodiments of the present application maximally maintains the state of the note page while ensuring that data is not lost, which is beneficial to improving the user experience.

[0128] S611. The main thread of the Activity loads picture A containing all the information of data 1 from the database.

[0129] In a possible implementation manner, when the display mode changes from the light mode to the dark mode, after the electronic device executes the above S611, the display screen of the electronic device can display an interface as shown in Figure 9The interface shown. It can be seen that Figure 1 and Figure 9 The difference is that Figure 9 the handwritten canvas is converted into a picture, and there is no handwritten input tool in the interface. In this case, the user can still convert the picture into an editable canvas by clicking on the picture or any other specified operation and continue handwritten input. This application does not make any limitations in this regard.

[0130] It should be noted that whether the main thread of the Activity executes S610 or S611, the empty picture stored in S603 above can exist. In the embodiments of this application, the property of the empty picture can be set to a property that is invisible to the user. In this way, the empty picture can be used to mark the size of the handwritten canvas and the position of the handwritten canvas in the entire note interface, and will not affect the content displayed in the UI during the UI restoration process of the Activity, which is beneficial to improving the user experience.

[0131] In a possible implementation manner, when the value of the flag bit 1 is not the target value 1, the main thread of the Activity can also execute S610. This application does not make any limitations in this regard.

[0132] Next, the data storage method provided by the embodiments of this application will be described in detail. This method is referred to as the first method in the following description. The first method can be applied to an electronic device, and its software structure can be as Figure 4 shown, and its hardware structure can be as Figure 10 shown, but this application does not make any specific limitations in this regard.

[0133] The first method includes: at a first moment, a first interface is displayed. The first interface includes a first canvas, and the first canvas is used to receive the user's writing operation and present the writing strokes. The first canvas is in a writable state, and the first interface is in a first display mode; at a second moment, a first operation that triggers a change in the display mode is received; at a third moment, a second interface is displayed. The second interface also includes the first canvas, and the first canvas is still in a writable state. The writing strokes in the first canvas are the same as those at the first moment. The second interface is displayed based on the first operation, and the second interface is in a second display mode, and the second display mode is different from the first display mode; wherein, the second moment is after the first moment, the third moment is after the second moment, and between the second moment and the third moment, the first canvas in the first interface fails to be saved as a picture, and the first canvas in the second interface is obtained based on the context of the writing strokes in the first canvas saved after the second moment.

[0134] It should be understood that a change in the display mode may cause the electronic device to refresh the display interface view. Exemplarily, a change in the display mode may refer to a change in the size of the display area or a change in the screen display mode. For example, the landscape mode changes to the portrait mode, or the portrait mode changes to the landscape mode. Moreover, for an electronic device with a foldable screen, the display screen is folded or unfolded. Additionally, the screen brightness changes from the light mode (day mode) to the dark mode (night mode) or from the dark mode to the light mode, etc. The present application does not limit this.

[0135] In some implementations, the electronic device includes a system interface control center, and the user can call out the system interface control center by swiping down the display screen of the electronic device from the upper right corner. Optionally, the first operation may be any operation of the user on the button for switching the display mode set in the system interface control center, such as clicking, double-clicking, swiping, etc. The first operation may also be any operation that can cause a change in the display mode through interaction with the voice assistant included in the electronic device. The embodiments of the present application do not limit this.

[0136] Exemplarily, the first interface may be Figure 1 the interface shown in Figure 1 and the first canvas may be the handwriting area 101 in Figure 8 The display mode of the first interface may be, for example, the light mode, or may also be referred to as the day mode, etc. The second interface may be Figure 8 the interface shown in

[0137] It should be understood that Figure 8 the handwriting area 801 in Figure 1 is restored from the data saved in the handwriting area 101 in Figure 8 Therefore, the handwriting area 801 in Figure 1 and the handwriting area 101 in Figure 8 can be understood as the same canvas. Or, the handwriting area 801 in Figure 1 can be understood as a canvas recreated based on the data saved in the handwriting area 101 in Figure 1 and is the same canvas as the handwriting area 101 in

[0138] The present application does not limit this.In an embodiment of the present application, the first canvas in the second interface is obtained based on the context of the writing strokes in the first canvas saved after the second moment. Since the storage process of the context of the writing strokes in the first canvas is relatively fast, it is conducive to quickly saving the handwritten data. During the process of the electronic device displaying the second interface, it can be restored based on the context of the writing strokes in the first canvas, which helps to avoid data loss.

[0139] It should be understood that the "context of the writing strokes in the first canvas" described here can have a similar meaning to the "context of the valid handwritten data" and "Data 2" involved above, and will not be repeated for explanation.

[0140] It should also be understood that in the related art, when it is necessary to store the data related to the first canvas, the implementation method is to store the view data of the first canvas as a picture, and each reporting point in the view data of the first canvas needs to be stored in the bitmap format. Since there is reporting point data without user writing strokes in the view data of the first canvas, its storage process is relatively slow. However, the context of the writing strokes in the first canvas stored in the embodiment of the present application, on the one hand, only includes the data with user writing strokes, and on the other hand, does not require complex format conversion, so the speed is faster. Therefore, it is conducive to quickly saving the user's handwritten data and avoiding the loss of handwritten data.

[0141] The so-called reporting point can be understood as a unit for the electronic device to record the user's writing strokes, which is used to define a region on the canvas. It can be a single pixel as a unit, or multiple pixels as a unit, or a unit defined by other measurement units, and can have a similar meaning to the "point position" mentioned in Method 600 above, and will not be repeated for explanation.

[0142] As an optional embodiment, the above first method further includes: at the fourth moment after the third moment, in response to a second operation on the second interface, display a third interface. The third interface includes a first picture, and the content presented by the first picture is the same as the writing strokes in the first canvas of the second interface. The third interface is also in the second display mode, and the second operation is used to exit the writable state of the first canvas in the second interface.

[0143] Exemplarily, the second operation can be a click operation by the user on the control 802 in the interface as shown in Figure 8 . In response to this operation, the third interface displayed by the electronic device can be as shown in Figure 9 . The first picture can be as shown in 901 in Figure 9 . The content presented by 901 is the same as the writing strokes in 801, except that 901 is in the form of a picture and is not writable. From Figures 8 to 9 , the display mode of the electronic device may not change.

[0144] As an alternative embodiment, the above first method further includes: at a fifth moment, a fourth interface is displayed. The fourth interface includes a second canvas, which is used to receive a user's writing operation and present the writing strokes. The second canvas is in a writable state, and the fourth interface is in a third display mode; at a sixth moment, a third operation that triggers a change in the display mode is received; at a seventh moment, a fifth interface is displayed. The fifth interface includes a second picture, and the content presented by the second picture is the same as the writing strokes in the second canvas. The fifth interface is displayed based on the third operation, and the fifth interface is in a fourth display mode, which is different from the third display mode. Among them, the sixth moment is after the fifth moment, and the seventh moment is after the sixth moment. Between the sixth moment and the seventh moment, after saving the context of the writing strokes in the second canvas, the electronic device successfully saves the view data of the second canvas as the second picture.

[0145] Exemplarily, the fourth interface may also be an interface as shown in Figure 1 , and the second canvas may also be Figure 1 the handwriting area 101 in, and the fifth interface may be an interface as shown in Figure 9 , and the second picture may be Figure 9 901 in.

[0146] Optionally, the view data of the second canvas may be, for example, the data 1 described above, and this application does not limit this.

[0147] In the embodiments of this application, after saving the context of the writing strokes in the second canvas, the electronic device successfully saves the view data of the second canvas as the second picture. Since the view data of the second canvas has been successfully saved as the second picture and the picture data has good stability, when the electronic device restores the second canvas, it can also restore the second canvas in the form of the second picture. In this way, the restored fifth interface is not prone to garbled characters, which is beneficial to providing a better user experience.

[0148] As an alternative embodiment, the electronic device includes a first application that supports the handwriting input function and receives a first operation that triggers a change in the display mode, including: the main thread receives the first operation that triggers a change in the display mode, and the main thread is the main thread for interface display in the first application; the method further includes: the main thread starts a process of destroying the main thread and launches a child thread based on the first operation. The child thread is a child thread of the main thread and is used to store data; the child thread obtains and saves the context of the writing strokes in the first canvas from the main thread; displaying a second interface, including: when the main thread is destroyed and then restarted, the restarted main thread loads the context of the writing strokes in the first canvas and displays the second interface using the context of the writing strokes in the first canvas.

[0149] Optionally, the first application may be a note application on an electronic device, or any other application that supports handwriting input. This application does not make any limitations in this regard.

[0150] It should be understood that the main thread may be the Activity of the note application, which is a visual user interface responsible for creating a screen window and placing UI components for user interaction. The child thread is a child thread pulled up by the main thread of the Activity and is used to store relevant data in the main thread of the Activity, such as data related to writing strokes. The child thread 1 mentioned in other places in the embodiments of this application may have a similar meaning to the child thread described here.

[0151] It should also be understood that when the main thread is destroyed, the child thread pulled up by the main thread is also destroyed synchronously. For an introduction to the life cycle of the main thread of the Activity, reference can be made to Figure 5 the corresponding description, which will not be elaborated here.

[0152] Furthermore, the "handwriting data", "writing strokes", etc. described in the embodiments of this application all refer to the data collected by the electronic device in the case of user handwriting input. This application does not make specific limitations on the specific content included in this data.

[0153] In the embodiments of this application, during the process of the main thread executing the destruction process, the child thread obtains and saves the context of the writing strokes in the first canvas from the main thread. During the process of the main thread restarting after being destroyed, the context of the writing strokes in the first canvas is loaded to restore the first canvas. In this way, it is beneficial to timely save the relevant data of the first canvas, reduce the possibility of the writing strokes in the first canvas being lost, and improve the user experience.

[0154] As an optional embodiment, further, during the process of the main thread being destroyed, the method further includes: the child thread sets a flag bit and sets the value of the flag bit to a first value, where the first value is used to indicate that the canvas cannot be saved as a picture; the child thread obtains the size data of the first canvas from the main thread; the child thread saves a third picture with the same size as the first canvas based on the size data of the first canvas, and the third picture does not contain visual content; when the restarted main thread loads the context of the writing strokes in the first canvas, it includes: when the restarted main thread determines that the value of the flag bit is the first value, it loads the third picture and the context of the writing strokes in the first canvas; when using the context of the writing strokes in the first canvas to display the second interface, it includes: the restarted main thread determines the size of the first canvas using the third picture, and loads the writing strokes in the first canvas on a canvas with the same size as the third picture to display the second interface.

[0155] Exemplarily, the implementation process of this embodiment may be similar to the process in method 600 where sub-thread 1 executes S601 - S605, and then the Activity main thread executes S608 - S610. The specific process can be referred to the description in method 600 and will not be elaborated here.

[0156] Optionally, the third picture may be the empty picture described in method 600. The meaning of the empty picture may be that it does not contain visual content, or it is completely transparent, or it only contains some default colors (such as white, black, or other solid colors, etc.). However, this application does not make specific limitations on this. The third picture is invisible to the user and can act as a placeholder in UI design.

[0157] As an alternative embodiment, the electronic device includes a first application that supports the handwriting input function and receives a third operation that triggers a change in the display mode, including: the main thread receives the third operation that triggers a change in the display mode, and the main thread is the main thread for interface display in the first application; the method further includes: the main thread starts a process to destroy the main thread and launches a sub-thread based on the third operation, and the sub-thread is a sub-thread of the main thread and is used to store data; the sub-thread sets a flag bit and sets the value of the flag bit to a first value, where the first value is used to indicate that the canvas cannot be saved as a picture; the sub-thread obtains the view data of the second canvas from the main thread, and the view data includes the size data of the second canvas and the color data of each reporting point in the second canvas; the sub-thread saves a fourth picture with the same size as the second canvas based on the size data of the second canvas, and the fourth picture does not contain visual content; the sub-thread obtains and saves the context of the handwriting in the second canvas from the main thread; in the case where the main thread has not been destroyed, the sub-thread saves the view data as a second picture based on the size data of the second canvas and the color data of each reporting point included in the view data; the sub-thread modifies the value of the flag bit to a second value, where the second value is used to indicate that the canvas has been successfully saved as a picture; displaying the fourth interface includes: in the case where the main thread is restarted after being destroyed, the restarted main thread loads the second picture to display the fourth interface when determining that the value of the flag bit is not the first value.

[0158] Exemplarily, the implementation process of this embodiment may be similar to the process in method 600 where sub-thread 1 executes S601 - S607, and then the Activity main thread executes S608 - S609 - S611. The specific process can be referred to the description in method 600 and will not be elaborated here.

[0159] Optionally, the fourth picture may have a similar meaning to the above-mentioned third picture and will not be elaborated here.

[0160] Optionally, the flag bit (which can be denoted as flag) can take values such as true, false, or binary numbers such as 0 and 1. This application does not make any limitations in this regard. Exemplarily, in the embodiments of this application, the flag bit can be, for example, the flag bit 1 described above, the first value can be the target value 1 described above, its value can be true, the second value can be the target value 2 described above, and its value can be false.

[0161] It can be seen that when the running time of the child thread is sufficient, after the child thread saves the context of the writing strokes in the second canvas, it can further save the view data of the second canvas as a second picture. During the process of the main thread being destroyed and restarted, the restarted main thread can restore the second canvas in the form of the second picture. In this way, the fifth interface restored by the electronic device is not prone to garbled characters, which is beneficial to providing a better user experience.

[0162] In the saving order of the embodiments of this application, at least the context of the writing strokes in the second canvas can be saved. On the premise of ensuring that the writing strokes in the second canvas are not lost, the view data of the second canvas can be further saved as a second picture. This is not only beneficial to reducing the risk of data loss but also conducive to maintaining the stability of the data and providing a better user experience.

[0163] Optionally, in this case, the restarted main thread can also restore the second canvas by using the context of the writing strokes in the second canvas, so that the user can directly enter the writable state of the second canvas, simplifying the user's operation.

[0164] Optionally, the main thread is the main thread of the interface activity Activity.

[0165] Optionally, the context of the writing strokes includes one or more of the following data for each reporting point in the writing strokes: position data, color data, or pen type data.

[0166] Among them, the position data can be coordinate data. For specific details, reference can be made to Figure 7 the description given, which will not be repeated here.

[0167] Optionally, the context of the writing strokes is saved in the ent file format and can be saved in the electronic device file system. The view data saved in the bitmap format of the picture can be saved in the electronic device database, but this application does not make any limitations in this regard.

[0168] So far, the data storage method of the embodiments of the present application has been described above. Next, the apparatus for executing the above method provided by the embodiments of the present application will be described. Those skilled in the art can understand that the method and the apparatus can be combined and cited with each other, and the relevant apparatus provided by the embodiments of the present application can execute the steps in the above method.

[0169] Figure 10 FIG. shows a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application. As Figure 10 shown, the electronic device may include a processor 1010, a memory 1020, a display screen 1030, a sensor module 1040, a universal serial bus (USB) interface 1050, a charging management module 1060, a power management module 1061, a battery 1062, etc.

[0170] The processor 1010 may include one or more processing units. For example, the processor 1010 may include a central processing unit (CPU), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

[0171] The memory 1020 may be used to store computer-executable program code, and the executable program code includes instructions, such as the program code corresponding to any of the above methods in the embodiments of the present application. The memory 1020 may also be used to store the handwritten data involved in the embodiments of the present application.

[0172] The display screen 1030 is used to display images, videos, etc. The display screen 1030 includes a display panel. In some embodiments, the electronic device may include 1 or N display screens 1030, where N is a positive integer greater than 1. The electronic device realizes the display function through the GPU, the display screen 1030, and the application processor, etc. In some implementations, the display screen may communicate with a touch sensor to collect signals generated by a user's touch operation.

[0173] In some implementations, the sensor module may include a touch sensor, also referred to as a "touch device". The touch sensor may be disposed on the display screen 1030, and together with the display screen, they form a touch screen, also known as a "touch panel". In the embodiments of the present application, the touch sensor can be used to detect touch operations acting on or near it. The touch sensor can transmit the detected touch operations to the application processor to determine the type of touch event. Visual outputs related to the touch operations can be provided through the display screen. In other embodiments, the touch sensor may also be disposed on the surface of the electronic device, at a different position from where the display screen 1030 is located.

[0174] It should be noted that the module names involved in the embodiments of the present application can all be defined as other names, as long as the functions of each module can be achieved, and no specific restrictions are imposed on the module names.

[0175] The data storage method provided by the embodiments of the present application can be applied to an electronic device with a handwriting function. The software structure of the electronic device can be as Figure 1 shown therein, and the hardware structure can be as Figure 10 shown therein. The specific form of the electronic device can be referred to the above description and will not be elaborated here.

[0176] Figure 11 An exemplary structural schematic diagram of a chip provided by the embodiment is shown. The chip 1100 includes one or more than two (including two) processors 1101, a communication line 1102, a communication interface 1103, and a memory 1104.

[0177] In some embodiments, the memory 1104 stores the following elements: executable modules or data structures, or subsets thereof, or extended sets thereof.

[0178] The method described in the embodiments of the present application above can be applied to or implemented by the processor 1101. The processor 1101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor 1101 or the instructions in the form of software. The above-mentioned processor 1101 may be a general-purpose processor (e.g., a microprocessor or a conventional processor), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate, transistor logic devices, or discrete hardware components. The processor 1101 can implement or execute various processing-related methods, steps, and logic block diagrams disclosed in the embodiments of the present application.

[0179] The steps of the method disclosed in combination with the embodiments of the present application can be directly implemented by the execution of the hardware decoding processor, or implemented by the combination of the hardware and software modules in the decoding processor. Among them, the software module can be located in mature storage media in the art such as random access memory, read-only memory, programmable read-only memory, or electrically erasable programmable read-only memory (EEPROM). This storage medium is located in the memory 1104, and the processor 1101 reads the information in the memory 1104 and combines its hardware to complete the steps of the above method.

[0180] Communication can be carried out between the processor 1101, the memory 1104, and the communication interface 1103 through the communication line 1102.

[0181] In the above embodiment, the instructions stored in the memory for the processor to execute can be implemented in the form of a computer program product. Among them, the computer program product can be pre-written in the memory in advance, or downloaded and installed in the memory in the form of software.

[0182] In the embodiments of the present application, the above chip 1100 may also be a chip system, for example: a system on chip (SOC), and the present application does not make any limitations in this regard.

[0183] An embodiment of the present application provides an electronic device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory stores computer program code, and the computer program code includes computer instructions; the one or more processors call the computer instructions to cause the electronic device to execute the method in the above embodiment.

[0184] An embodiment of the present application provides a chip or a chip system. The chip or the chip system is applied to an electronic device, and the chip or the chip system includes one or more processors, and the one or more processors are used to call computer instructions to cause the electronic device to execute the method in the above embodiment. The implementation principle and technical effect are similar to those of the above related embodiments, and will not be elaborated here.

[0185] An embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium includes computer instructions. When the computer instructions run on an electronic device, the electronic device is caused to execute the method in the above embodiment. The method described in the above embodiment can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the functions can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. The computer-readable medium may include a computer storage medium and a communication medium, and may also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium accessible by a computer.

[0186] In a possible implementation, the computer-readable medium may include RAM, ROM, a compact disc read-only memory (CD-ROM), or other optical disc memories, magnetic disk memories, or other magnetic storage devices, or any other medium targeted to carry or store the required program code in the form of instructions or data structures and accessible by a computer. Moreover, any connection is properly referred to as a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of the medium. As used herein, disk and optical disc include optical disc, laser disc, optical disc, digital versatile disc (DVD), floppy disk, and Blu-ray disc, where disks typically reproduce data magnetically, while optical discs utilize laser optics to reproduce data. The above combinations should also be included within the scope of the computer-readable medium.

[0187] An embodiment of the present application provides a computer program product, which includes computer program code. When the computer program code runs on an electronic device, the electronic device is caused to execute the method in the above embodiment.

[0188] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable devices to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing devices generate means for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or multiple blocks.

[0189] The above specific implementation manners further elaborate on the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are only specific implementation manners of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solution of the present invention shall be included in the protection scope of the present invention.

Claims

1. A data storage method, characterized in that: Applied to electronic equipment, the method comprises: At a first moment, a first interface is displayed, the first interface includes a first canvas, the first canvas is used to receive a writing operation of a user and present the writing handwriting, the first canvas is in a writable state, and the first interface is in a first display mode; At a second moment, a first operation that triggers a change in display mode is received; At a third moment, a second interface is displayed, the second interface also includes the first canvas, the first canvas is still in a writable state, the handwriting in the first canvas is the same as at the first moment, the second interface is displayed based on the first operation, the second interface is in a second display mode, and the second display mode is different from the first display mode; The second moment is after the first moment, the third moment is after the second moment, and between the second moment and the third moment, the first canvas in the first interface cannot be saved as a picture, and the first canvas in the second interface is obtained based on the context of the handwriting in the first canvas saved after the second moment.

2. The method according to claim 1, characterized in that: The method further comprises: At a fourth moment after the third moment, in response to a second operation on the second interface, a third interface is displayed, the third interface including a first picture, the content presented by the first picture is the same as the writing handwriting in the first canvas of the second interface, the third interface is also in the second display mode, and the second operation is used to exit the writable state of the first canvas in the second interface.

3. The method according to claim 1, characterized in that The method further comprises: At the fifth moment, a fourth interface is displayed, wherein the fourth interface includes a second canvas, wherein the second canvas is used to receive a writing operation of the user and present the writing handwriting, the second canvas is in a writable state, and the fourth interface is in the third display mode; At a sixth moment, a third operation triggering a display mode change is received; At the seventh moment, a fifth interface is displayed, the fifth interface includes a second picture, the content presented by the second picture is the same as the handwriting in the second canvas, the fifth interface is displayed based on the third operation, the fifth interface is in a fourth display mode, and the fourth display mode is different from the third display mode; Among them, the sixth moment is after the fifth moment, the seventh moment is after the sixth moment, and between the sixth moment and the seventh moment, the electronic device successfully saves the view data of the second canvas as the second picture after saving the context of the writing handwriting in the second canvas.

4. The method according to claim 2, characterized in that: The method further comprises: At the fifth moment, a fourth interface is displayed, wherein the fourth interface includes a second canvas, wherein the second canvas is used to receive a writing operation of the user and present the writing handwriting, the second canvas is in a writable state, and the fourth interface is in the third display mode; At a sixth moment, a third operation triggering a display mode change is received; At the seventh moment, a fifth interface is displayed, the fifth interface includes a second picture, the content presented by the second picture is the same as the handwriting in the second canvas, the fifth interface is displayed based on the third operation, the fifth interface is in a fourth display mode, and the fourth display mode is different from the third display mode; Among them, the sixth moment is after the fifth moment, the seventh moment is after the sixth moment, and between the sixth moment and the seventh moment, the electronic device successfully saves the view data of the second canvas as the second picture after saving the context of the writing handwriting in the second canvas.

5. The method according to any one of claims 1 to 4, characterized in that The electronic device includes a first application, the first application supports a handwriting input function, and the receiving a first operation that triggers a display mode change includes: The main thread receives a first operation that triggers a display mode change, and the main thread is a main thread for interface display in the first application; The method further comprises: The main thread starts a process of destroying the main thread based on the first operation and starts a child thread, where the child thread is a child thread of the main thread and is used to store data; The child thread obtains and saves the context of the handwriting in the first canvas from the main thread; The displaying of the second interface includes: In the case where the main thread is destroyed and then restarted, the restarted main thread loads the context of the handwriting in the first canvas, and uses the context of the handwriting in the first canvas to display the second interface.

6. The method according to claim 5, characterized in that During the main thread destruction process, the method further includes: The child thread sets a flag bit, and sets the value of the flag bit to a first value, where the first value is used to indicate that the canvas cannot be saved as a picture; The child thread obtains the size data of the first canvas from the main thread; The child thread saves a third picture having the same size as the first canvas based on the size data of the first canvas, wherein the third picture does not contain any visual content; The restarted main thread loads the context of the handwriting in the first canvas, including: The restarted main thread loads the third picture and the context of the handwriting in the first canvas when determining that the value of the mark bit is the first value; The displaying of the second interface by using the context of the handwriting in the first canvas includes: The restarted main thread determines the size of the first canvas using the third picture, and loads the writing in the first canvas onto a canvas having the same size as the third picture to display the second interface.

7. The method according to claim 3 or 4, characterized in that: The electronic device includes a first application, the first application supports a handwriting input function, and the receiving a third operation that triggers a display mode change includes: The main thread receives a third operation that triggers a display mode change, the main thread being the main thread used for interface display in the first application, and the main thread being the main thread used for interface display in the first application; The method further comprises: The main thread starts a process of destroying the main thread based on the third operation and starts a child thread, where the child thread is a child thread of the main thread and is used to store data; The child thread sets a flag bit, and sets the value of the flag bit to a first value, where the first value is used to indicate that the canvas cannot be saved as a picture; The child thread obtains the view data of the second canvas from the main thread, where the view data includes size data of the second canvas and color data of each point in the second canvas; The child thread saves a fourth picture having the same size as the second canvas based on the size data of the second canvas, wherein the fourth picture does not contain any visual content; The child thread obtains and saves the context of the handwriting in the second canvas from the main thread; In a case where the main thread has not been destroyed, the child thread saves the view data as the second picture based on the size data of the second canvas and the color data of each point in the second canvas included in the view data; The child thread modifies the value of the flag bit to a second value, where the second value is used to indicate that the canvas has been successfully saved as a picture; The displaying of the fourth interface includes: In the case where the main thread is destroyed and then restarted, the restarted main thread loads the second image to display the fourth interface when it is determined that the value of the flag bit is not the first value.

8. The method according to claim 5, characterized in that The main thread is the main thread of the interface activity Activity.

9. The method according to claim 1, characterized in that: The context of the handwriting includes one or more of the following data for each reported point in the handwriting: position data, color data or pen type data.

10. The method according to claim 1, characterized in that The context of the written handwriting is saved in the ent file format.

11. An electronic device, characterized in that: The electronic device comprises: one or more processors and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method according to any one of claims 1 to 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 as described in any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device is caused to perform the method according to any one of claims 1 to 10.

14. A computer program product, characterized in that The computer program product comprises a computer program code, and when the computer program code is run on an electronic device, the electronic device is caused to perform the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Writing note data storage method and device, terminal and storage medium

    CN108763320A

  • Note-taking generation method, electronic device, and computer storage medium

    CN109085965A