WO2022057663A1 - 一种生成文件的方法及电子设备 - Google Patents

一种生成文件的方法及电子设备 Download PDF

Info

Publication number
WO2022057663A1
WO2022057663A1 PCT/CN2021/116745 CN2021116745W WO2022057663A1 WO 2022057663 A1 WO2022057663 A1 WO 2022057663A1 CN 2021116745 W CN2021116745 W CN 2021116745W WO 2022057663 A1 WO2022057663 A1 WO 2022057663A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
resource
resource file
page
electronic device
Prior art date
Application number
PCT/CN2021/116745
Other languages
English (en)
French (fr)
Inventor
王燊
高杨
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP21868488.4A priority Critical patent/EP4206955A4/en
Priority to US18/027,035 priority patent/US20230376459A1/en
Publication of WO2022057663A1 publication Critical patent/WO2022057663A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Definitions

  • the present application relates to the field of electronic technology, and in particular, to a method and electronic device for generating a file.
  • the display screen of the electronic device will display the relevant page of the APP.
  • the electronic The device displays the home page of the Huawei Game APP.
  • the installation package of the APP usually contains various files, such as page layout files, image resource files, media resource files, etc., wherein the page layout files can describe all resource files required by the pages of the APP.
  • the operating system determines the resource file required by the page to be displayed by the APP according to the page layout file, and displays the resource file to the user through the display screen after loading the resource file.
  • the present application provides a method and electronic device for generating a file.
  • the page layout files corresponding to each page of the APP are parsed, and the original resource files belonging to the same page or pages with an associated relationship are merged into one file,
  • the page is displayed, when the original resource file is loaded, the resource file generated after the merge is actually loaded, and the original resource file is sequentially read from the resource file generated after the merge.
  • the files are loaded in turn and then read, thereby improving the speed of reading the original resource file when the page is displayed, thereby improving the display speed of the page.
  • a first aspect provides a method applied to an electronic device, the method comprising: obtaining first information according to a resource index file, the resource index file including indexes, file names and path information of multiple resource files, the multiple Each resource file includes a first resource file and a second resource file, and the first information includes the path information and file name of the first file; according to the first information, the first file is loaded, and the first file is Generated by merging the first resource file and the second resource file, the first resource file and the second resource file belong to the first page; according to the second information, obtained from the first file the first resource file and the second resource file, the second information is used to extract the first resource file and the second resource file from the first resource file; according to the first resource file and the second resource file, the electronic device displays the first page.
  • the process of loading a file involved in the embodiments of the present application may be a process of first reading the file from the non-volatile memory, and then storing the read file in the random access memory.
  • the first file when loading the first file, the first file may be read out from the non-volatile memory, and then the first file may be stored in the random access memory.
  • the original resource files belonging to the same page are merged into one file, so that when the page is displayed, when the original resource file is loaded, the actual loading It is the resource file generated after merging.
  • the resource file generated after merging when loading the resource file generated after merging, read the resource file generated after merging from non-volatile memory, and then store the resource file generated after merging in random storage.
  • the original resource file can be continuously read from the resource file generated after the merge, without the need to load and read the original resource file in sequence when the page is displayed, thereby improving the speed of reading the original resource file when the page is displayed. , thereby improving the display speed of the page.
  • the methods provided by the embodiments of the present application do not limit the number of original resource files included in a page. In other words, the methods provided by the embodiments of the present application are also applicable to a situation where a page includes multiple original resource files.
  • the second information includes an offset of the start position of the first resource file relative to the start position of the first file and the offset of the starting position of the second resource file relative to the starting position of the first file.
  • the electronic device when performing page display, can determine the position of the first resource file in the first file and the length of the first resource file according to the second information, and determine that the second resource file is in the first file. According to the position and length of the second resource file, the first resource file and the second resource file are sequentially obtained from the first file, so that the first page is displayed according to the first resource file and the second resource file.
  • the second information includes the length of the first resource file and the length of the second resource file.
  • the electronic device when performing page display, can determine the position of the first resource file in the first file and the length of the first resource file according to the second information, and determine that the second resource file is in the first file. According to the position and length of the second resource file, the first resource file and the second resource file are sequentially obtained from the first file, so that the first page is displayed according to the first resource file and the second resource file.
  • the second information is stored in the first file or the resource index file.
  • the electronic device can obtain the second information relatively quickly, and obtain the second information from the first file according to the second information the first resource file and the second resource file, thereby improving the speed of displaying the first page according to the first resource file and the second resource file.
  • the first resource file is of the same type as the second resource file.
  • the length of the first file is less than or equal to a preset threshold.
  • the length of the resource file generated after merging is limited to be less than or equal to the preset threshold, thereby Improve display speed.
  • a method for generating a file comprising: acquiring a page layout file of a first page; and determining, according to the page layout file of the first page, that the first page includes a first resource file and a second resource file; combine the first resource file and the second resource file to generate a first file.
  • the process of loading a file involved in the embodiment of the present application may be a process of first reading the file from the non-volatile memory, and then storing the read file in the random access memory.
  • the first file when loading the first file, the first file may be read out from the non-volatile memory, and then the first file may be stored in the random access memory.
  • the original resource files belonging to the same page are merged into one file, so that when the page is displayed, when the original resource file is loaded, the actual loading It is the resource file generated after merging.
  • the resource file generated after merging when loading the resource file generated after merging, read the resource file generated after merging from non-volatile memory, and then store the resource file generated after merging in random storage.
  • the original resource file can be continuously read from the resource file generated after the merge, without the need to load and read the original resource file in sequence when the page is displayed, thereby improving the speed of reading the original resource file when the page is displayed. , thereby improving the display speed of the page.
  • the method for generating a file provided by the embodiment of the present application does not limit the number of original resource files included in a page. In other words, the method for generating a file provided by the embodiment of the present application is also applicable to a page including multiple The case of the original resource file.
  • the determining, according to the page layout file of the first page, that the first page includes a first resource file and a second resource file includes: according to the The identifier of the first resource file and the identifier of the second resource file included in the page layout file of the first page are used to determine that the first resource file and the second resource file belong to the first page.
  • the first file stores the offset of the starting position of the first resource file relative to the starting position of the first file and the offset of the starting position of the first file.
  • the offset of the starting position of the second resource file relative to the starting position of the first file, and/or the first file stores the length of the first resource file and the first 2. The length of the resource file.
  • the electronic device when performing page display, can determine the position of the first resource file in the first file and the length of the first resource file according to the second information, and determine that the second resource file is in the first file. According to the position and length of the second resource file, the first resource file and the second resource file are sequentially obtained from the first file, so that the first page is displayed according to the first resource file and the second resource file.
  • the method further includes: generating a resource index file, where the resource index file includes indexes, file names and path information of multiple resource files, the multiple The resource file includes the first resource file and the second resource file.
  • the resource index file stores the offset of the starting position of the first resource file relative to the starting position of the first file and the offset of the starting position of the first file.
  • the offset of the starting position of the second resource file relative to the starting position of the first file, and/or the first file stores the length of the first resource file and the first 2. The length of the resource file.
  • the first resource file and the second resource file are determined according to at least one page layout file of the first page.
  • the first resource file is of the same type as the second resource file.
  • the length of the first file is less than or equal to a preset threshold.
  • the length of the resource file generated after merging is limited, for example, the length of the first file is limited to be less than or equal to the preset threshold, thereby Speed up the display.
  • a method is provided, applied to an electronic device including a display screen, wherein the method includes: acquiring a page layout file of a first page; and determining the page layout file according to at least one page layout file of the first page.
  • the first page includes a first resource file and a second resource file; the first resource file and the second resource file are combined to generate a first file; according to the resource index file, the first information is obtained, and the resource index
  • the file includes indexes, file names and path information of multiple resource files, the multiple resource files include the first resource file and the second resource file, and the first information includes path information of the first file and file name; load the first file according to the first information; load the first file according to the first information; obtain the first resource file from the first file according to the second information and the second resource file, the second information is used to extract the first resource file and the second resource file from the first resource file; according to the first resource file and the second resource file, the electronic device displays the first page.
  • the process of loading a file involved in the embodiments of the present application may be a process of first reading the file from the non-volatile memory, and then storing the read file in the random access memory.
  • the first file when loading the first file, the first file may be read out from the non-volatile memory, and then the first file may be stored in the random access memory.
  • the original resource files belonging to the same page are merged into one file, so that when the page is displayed, when the original resource file is loaded, the actual loading It is the resource file generated after merging.
  • the resource file generated after merging when loading the resource file generated after merging, read the resource file generated after merging from non-volatile memory, and then store the resource file generated after merging in random storage.
  • the original resource file can be continuously read from the resource file generated after the merge, without the need to load and read the original resource file in sequence when the page is displayed, thereby improving the speed of reading the original resource file when the page is displayed. , thereby improving the display speed of the page.
  • the methods provided by the embodiments of the present application do not limit the number of original resource files included in a page. In other words, the methods provided by the embodiments of the present application are also applicable to a situation where a page includes multiple original resource files.
  • a file including a first file generated according to the method for generating a file in the second aspect, and/or including a resource index file generated according to the method for generating a file in the second aspect.
  • an electronic device comprising a display screen, a memory, one or more processors, and one or more programs; wherein the one or more programs are stored in the memory; the one or more programs When executing the one or more programs, the plurality of processors cause the electronic device to execute the method in any possible implementation of any one of the above aspects.
  • an electronic device comprising a memory, one or more processors, and one or more programs; wherein the one or more programs are stored in the memory; the one or more processes When the computer executes the one or more programs, the electronic device causes the electronic device to execute the method for generating a file in any possible implementation of any one of the above aspects.
  • an apparatus comprising a processing module and a display module, the processing module is configured to obtain first information according to a resource index file, the resource index file includes indexes, file names and path information of a plurality of resource files, so The multiple resource files include a first resource file and a second resource file, and the first information includes path information and file name of the first file; the processing module is further configured to load the first file according to the first information , the first file is generated by merging the first resource file and the second resource file, and the first resource file and the second resource file belong to the first page; the processing module is further configured to the second information, the first resource file and the second resource file are obtained from the first file, and the second information is used to extract the first resource file and the second resource file from the first resource file the second resource file; the display module is configured to display the first page according to the first resource file and the second resource file.
  • the second information includes an offset of the start position of the first resource file relative to the start position of the first file and the offset of the starting position of the second resource file relative to the starting position of the first file.
  • the second information includes the length of the first resource file and the length of the second resource file.
  • the second information is stored in the first file or the resource index file.
  • the first resource file and the second resource file are of the same type.
  • the length of the first file is less than or equal to a preset threshold.
  • an apparatus including a processing module, the processing module is configured to obtain a page layout file of a first page; the processing module is further configured to determine, according to the page layout file of the first page, that the first page includes a first resource file and a second resource file; the processing module is further configured to combine the first resource file and the second resource file to generate a first file.
  • the processing module is further configured to match the identifier of the first resource file included in the page layout file of the first page with the first resource file.
  • the identifier of the second resource file determines that the first resource file and the second resource file belong to the first page.
  • the first file stores the starting position of the first resource file relative to the starting position of the first file.
  • the offset from the starting position of the second resource file relative to the starting position of the first file, and/or the length of the first resource file is stored in the first file and the length of the second resource file.
  • the processing module is further configured to generate a resource index file, and the resource index file includes indexes, file names and path information of multiple resource files.
  • the plurality of resource files include the first resource file and the second resource file.
  • the resource index file stores the starting position of the first resource file relative to the starting position of the first file.
  • the offset from the starting position of the second resource file relative to the starting position of the first file, and/or the length of the first resource file is stored in the first file and the length of the second resource file.
  • the first resource file and the second resource file are determined according to at least one page layout file of the first page.
  • the first resource file and the second resource file are of the same type.
  • the length of the first file is less than or equal to a preset threshold.
  • a ninth aspect provides an apparatus, a processing module and a display module, the processing module is configured to obtain a page layout file of a first page; the processing module is further configured to determine the first page according to at least one page layout file of the first page It includes a first resource file and a second resource file, and the first information includes the path information and file name of the first file; the processing module is further configured to combine the first resource file and the second resource file. , and generate the first file; the processing module is further configured to obtain the first information according to the resource index file, the resource index file includes the index, file name and path information of multiple resource files, and the multiple resource files include the first information.
  • the processing module is further configured to load the first file according to the first information; the processing module is further configured to load the first file according to the first information; the processing module is further configured to load the first file according to the first information; for obtaining the first resource file and the second resource file from the first file according to second information, where the second information is used to extract the first resource from the first resource file file and the second resource file; the display module is configured to display the first page according to the first resource file and the second resource file.
  • the present application provides a computer storage medium, including computer instructions, which, when the computer instructions are executed on an electronic device, cause the electronic device to perform any of the possible methods in any of the foregoing aspects.
  • the present application provides a computer storage medium, including computer instructions, which, when the computer instructions are executed on an electronic device, cause the electronic device to execute any possible method for generating a file in any of the foregoing aspects.
  • the present application provides a computer program product, which, when the computer program product is run on an electronic device, enables the electronic device to perform any of the possible methods in any of the foregoing aspects.
  • the present application provides a computer program product that, when the computer program product runs on an electronic device, enables the electronic device to execute any of the possible methods for generating a file in any of the above aspects.
  • FIG. 1 is a schematic diagram of an interface provided by an embodiment of the present application.
  • FIG. 2 is a schematic structural diagram of an example of an electronic device provided by an embodiment of the present application.
  • FIG. 3 is a schematic diagram of an application scenario of the method for generating a file provided by an embodiment of the present application
  • Figure (b) in FIG. 3 is a schematic diagram of another application scenario of the method for generating a file provided by an embodiment of the present application;
  • Figure (c) in FIG. 3 is a schematic diagram of another application scenario of the method for generating a file provided by an embodiment of the present application;
  • FIG. 3 is a schematic diagram of still another application scenario of the method for generating a file provided by an embodiment of the present application;
  • FIG. 4 is a schematic flowchart of a method for generating a file provided by an embodiment of the present application
  • FIG. 5 is a schematic diagram of a merging process of original resource files provided by an embodiment of the present application
  • Figure (b) in Figure 5 is a schematic diagram of a merged file provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of an example of a resource index file provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of another example of a resource index file provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of another example of a merging process of original resource files provided by an embodiment of the present application.
  • FIG. 7 is a schematic flowchart of a method provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of an example of a loading process of an original resource file provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of another example of a loading process of an original resource file provided by an embodiment of the present application.
  • FIG. 10 is a schematic diagram of another example of the loading process of the original resource file provided by the embodiment of the present application.
  • FIG. 11 is another schematic flowchart of the method provided by the embodiment of the present application.
  • first and second are only used for descriptive purposes, and should not be construed as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, a feature defined with “first” and “second” may explicitly or implicitly include one or more of the features, for example, the "first resource file” and “second resource file” described in the embodiments of this application document”.
  • the embodiment of the present application provides a method for generating a file.
  • the page layout files corresponding to each page of the APP are parsed, and the original resource files belonging to the same page are combined into one file, so that when the page is displayed,
  • the merged file is actually loaded, and the original resource file is obtained in sequence from the merged file, so there is no need to load the original resource file in turn when the page is displayed, thereby reducing the number of times when the resource file is loaded when the page is displayed. , to improve the display speed of the page.
  • the resource file before merging is referred to as the original resource file
  • the resource file generated after merging the original resource files is referred to as a merged file.
  • the embodiment of the present application provides a method, when the page is displayed, by loading the merged file and sequentially obtaining the original resource files from the merged file, it is not necessary to load the original resource files in sequence when the page is displayed, so that when the page is displayed Reduce the number of loading original resource files and improve the display speed of the page.
  • the method and method for generating a file provided by the embodiments of the present application can be applied to augmented reality (AR)/virtual reality (VR) devices, mobile phones, tablet computers, wearable devices, in-vehicle devices, notebook computers, super Mobile personal computer (ultra-mobile personal computer, UMPC), netbook, personal digital assistant (personal digital assistant, PDA) and other electronic devices.
  • AR augmented reality
  • VR virtual reality
  • mobile phones mobile phones
  • tablet computers wearable devices
  • in-vehicle devices notebook computers
  • personal digital assistant personal digital assistant, PDA
  • PDA personal digital assistant
  • the page of the APP can be understood as the content displayed on the display interface of the electronic device when the electronic device detects the operation of the user to start the APP, or, after the APP is started, the electronic device detects that the user switches the page. During operation, in response to the operation, the content displayed on the display interface of the electronic device.
  • the page of the APP can be understood as that when the electronic device detects an operation of the user to start the Huawei game APP, in response to the operation, the display interface of the electronic device displays the home page of the Huawei game APP, and the The interface content 101 is shown in (a) of FIG. 1 , or, after the Huawei game APP is started, when the electronic device detects the user's operation of switching from the home page to the attention page, in response to the operation, the electronic device The displayed attention page, the interface content 102 of the attention page is shown in (b) of FIG. 1 .
  • the page layout file and the original resource file are both files introduced by the developer in the development process of the APP.
  • the page layout file is used to describe various original resource files required for the display of each page of the APP, wherein each page corresponds to A page layout file, when the electronic device displays the corresponding page, it determines the original resource file included in the display of the current page by parsing the page layout file, obtains the corresponding original resource file and displays the original resource file on the page through the display screen of the electronic device the corresponding location.
  • the original resource file may be, for example, a picture, text, etc. included in the page of the APP.
  • the original resource file index can be generated for the original resource file referenced by the APP, and the file name of the original resource file referenced in the page layout file can be replaced with the index of the original resource file.
  • the index, file name, and path information of the resource file generate a resource index file.
  • the resource index file stores the file name of the merged file and the path information of the merged file.
  • a merged file 1-4.png is generated.
  • the file names of 1.png and 4.xml are the file names of the merged file. Therefore, the index of 1.png is in The corresponding file name in the resource index file is consistent with the file name corresponding to the index of 4.xml in the resource index file, and the path information corresponding to the index of 1.png in the resource index file and the index of 4.xml in the resource index The corresponding path information in the file is consistent.
  • an index may also be generated for the page layout file, and a resource index file may be generated according to the index of the page layout file, the file name of the page layout file, and the path information of the page layout file. It should be understood that the resource index file generated for the page layout file and the resource index file generated for the resource file may be the same file, or may be different files, which are not limited in this embodiment of the present application.
  • the APP is a Huawei game APP
  • the electronic device displays the home page of the Huawei game APP
  • the file name of the page layout file of the home page and the resource index file of the page layout file are determined. path information, and then obtain the page layout file, determine the index of the resource files included in the home page according to the page layout file corresponding to the home page, find the file name and path information of the merged file in the resource index file according to the index, and then obtain the merged file
  • the display of the home page is completed according to the original resource file obtained from the merged file.
  • FIG. 2 is a schematic structural diagram of an example of an electronic device 100 provided by an embodiment of the present application.
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195 and so on.
  • SIM Subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
  • the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or less components than shown, or combine some components, or separate some components, or arrange different components.
  • the illustrated components may be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU) Wait.
  • application processor application processor, AP
  • modem processor graphics processor
  • graphics processor graphics processor
  • image signal processor image signal processor
  • ISP image signal processor
  • controller memory
  • video codec digital signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • different processing units can be independent devices, or can be integrated in one or more processors.
  • the controller may be the nerve center and command center of the electronic device 100 .
  • the controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in processor 110 is cache memory. This memory may hold instructions or data that have just been used or recycled by the processor 110 . If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
  • the processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transceiver
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL).
  • the processor 110 may contain multiple sets of I2C buses.
  • the processor 110 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193 and the like through different I2C bus interfaces.
  • the processor 110 may couple the touch sensor 180K through the I2C interface, so that the processor 110 and the touch sensor 180K communicate with each other through the I2C bus interface, so as to realize the touch function of the electronic device 100 .
  • the I2S interface can be used for audio communication.
  • the processor 110 may contain multiple sets of I2S buses.
  • the processor 110 may be coupled with the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170 .
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
  • the PCM interface can also be used for audio communications, sampling, quantizing and encoding analog signals.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193 .
  • MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc.
  • the processor 110 communicates with the camera 193 through a CSI interface, so as to realize the photographing function of the electronic device 100 .
  • the processor 110 communicates with the display screen 194 through the DSI interface to implement the display function of the electronic device 100 .
  • the GPIO interface can be configured by software.
  • the GPIO interface can be configured as a control signal or as a data signal.
  • the GPIO interface may be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and the like.
  • the GPIO interface can also be configured as I2C interface, I2S interface, UART interface, MIPI interface, etc.
  • the USB interface 130 is an interface that conforms to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like.
  • the USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones.
  • the interface can also be used to connect other electronic devices, such as AR devices.
  • the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 .
  • the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
  • the charging management module 140 is used to receive charging input from the charger.
  • the charger may be a wireless charger or a wired charger. While the charging management module 140 charges the battery 142 , it can also supply power to the electronic device through the power management module 141 .
  • the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140 and supplies power to the processor 110 , the internal memory 121 , the external memory, the display screen 194 , the camera 193 , and the wireless communication module 160 .
  • the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, battery health status (leakage, impedance).
  • the power management module 141 may also be provided in the processor 110 .
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • the wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, the baseband processor, and the like.
  • the electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
  • Display screen 194 is used to display images, videos, and the like.
  • Display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light).
  • LED diode AMOLED
  • flexible light-emitting diode flexible light-emitting diode (flex light-emitting diode, FLED), MiniLED, MicroLED, Micro-OLED, quantum dot light-emitting diode (quantum dot light emitting diodes, QLED) and so on.
  • the electronic device 100 may include one or N display screens 194 , where N is a positive integer greater than one.
  • the electronic device 100 may implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
  • the ISP is used to process the data fed back by the camera 193 .
  • the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye.
  • ISP can also perform algorithm optimization on image noise, brightness, and skin tone.
  • ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera 193 .
  • Camera 193 is used to capture still images or video.
  • the object is projected through the lens to generate an optical image onto the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
  • the ISP outputs the digital image signal to the DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
  • the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
  • a digital signal processor is used to process digital signals, in addition to processing digital image signals, it can also process other digital signals.
  • Video codecs are used to compress or decompress digital video.
  • the NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transfer mode between neurons in the human brain, it can quickly process the input information, and can continuously learn by itself. Applications such as intelligent cognition of the electronic device 100 can be realized through the NPU, for example: image recognition, face recognition, speech recognition, text understanding, etc.
  • the internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
  • RAM random access memories
  • NVM non-volatile memories
  • Random access memory can include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronization Dynamic random access memory (double data rate synchronous dynamic random access memory, DDR SDRAM, such as the fifth generation DDR SDRAM is generally called DDR5 SDRAM) and so on.
  • SRAM static random-access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR5 SDRAM double data rate synchronous dynamic random access memory
  • Non-volatile memory may include magnetic disk storage devices, flash memory.
  • Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle, and can include single-level memory cells (single-level cells, SLC), multi-level memory cells (multi-level memory cells) according to the level of storage cell potential cell, MLC), triple-level cell (TLC), fourth-level storage unit (quad-level cell, QLC), etc., according to the storage specification can include universal flash storage (English: universal flash storage, UFS) , embedded multimedia memory card (embedded multi media Card, eMMC) and so on.
  • SLC single-level memory cells
  • multi-level memory cells multi-level memory cells
  • MLC multi-level memory cells
  • TLC triple-level cell
  • QLC fourth-level storage unit
  • UFS universal flash storage
  • eMMC embedded multimedia memory card
  • the random access memory can be directly read and written by the processor 110, and can be used to store executable programs (eg, machine instructions) of an operating system or other running programs, and can also be used to store data of users and application programs.
  • executable programs eg, machine instructions
  • the random access memory can be directly read and written by the processor 110, and can be used to store executable programs (eg, machine instructions) of an operating system or other running programs, and can also be used to store data of users and application programs.
  • the non-volatile memory can also store executable programs and store data of user and application programs, etc., and can be loaded into the random access memory in advance for the processor 110 to directly read and write.
  • the external memory interface 120 can be used to connect an external non-volatile memory, so as to expand the storage capacity of the electronic device 100 .
  • the external non-volatile memory communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example, save music, video, etc. files in external non-volatile memory.
  • the electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playback, recording, etc.
  • the keys 190 of the electronic device 100 may include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key.
  • Motor 191 can generate vibrating cues. The motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback.
  • the indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.
  • the SIM card interface 195 is used to connect a SIM card.
  • the electronic device 100 also includes various sensors, for example, the pressure sensor 180A is used to sense pressure signals, and can convert the pressure signals into electrical signals.
  • the gyro sensor 180B may be used to determine the motion attitude of the electronic device 100 .
  • the air pressure sensor 180C is used to measure air pressure.
  • the magnetic sensor 180D includes a Hall sensor.
  • the acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes).
  • Distance sensor 180F for measuring distance.
  • the electronic device 100 can measure the distance through infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
  • Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes.
  • the ambient light sensor 180L is used to sense ambient light brightness.
  • the electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, accessing application locks, taking photos with fingerprints, answering incoming calls with fingerprints, and the like.
  • Touch sensor 180K also called "touch panel”.
  • the touch sensor 180K may be disposed on the display screen 194 , and the touch sensor 180K and the display screen 194 form a touch screen, also referred to as a "touch screen”.
  • the touch sensor 180K is used to detect a touch operation on or near it.
  • the touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
  • the bone conduction sensor 180M can acquire vibration signals.
  • the following embodiments of the present application will take an electronic device having the structure shown in FIG. 2 as an example, and take a Huawei game APP as an example, to specifically describe the method and method for generating a file provided by the embodiments of the present application.
  • An application scenario is shown in (a) of Figure 3.
  • the developer can use the packaging tool to merge the original resource files referenced by the Huawei game APP according to method 200, and then Upload the compiled Huawei game APP executable file to the application server, and users can download the Huawei game APP from the application server to the electronic device; another application scenario is shown in (b) in Figure 3.
  • the application server compiles the original code of the Huawei game APP, and in the compilation stage, the original resource files in the Huawei game APP are merged according to method 200, and finally the executable code of the Huawei game APP is generated.
  • the user can download the Huawei game APP from the application server to the electronic device; another application scenario is shown in (c) in Figure 3.
  • the server merges the original resource files in the HUAWEI game APP according to method 200, and the user can download the HUAWEI game APP from the application server to the electronic device; another application scenario such as As shown in (d) of FIG. 3 , after the user downloads the Huawei game APP from the application server to the electronic device, the electronic device merges the original resource files in the Huawei game APP according to method 200 .
  • This embodiment of the present application does not limit this.
  • FIG. 4 shows a schematic flowchart of a method 200 of generating a file.
  • the method 200 includes the following steps.
  • Step 210 acquiring the page layout file of the first page.
  • Step 220 According to the page layout file of the first page, it is determined that the first page includes the first resource file and the second resource file.
  • Step 230 Combine the first resource file and the second resource file to generate a first file.
  • the packaging tool determines the original resource files belonging to the same page from all the original resource files of the Huawei game APP according to the page layout files corresponding to each page of the Huawei game APP.
  • the files are merged to generate a merged file.
  • the packaging tool in the compilation stage of the Huawei game APP, the packaging tool generates a merged file according to the identifiers of the original resource files included in the three page layout files of the Huawei game APP.
  • These three page layout files correspond to the three pages of the Huawei game APP, which are denoted as page 1, page 2, and page 3.
  • the identifier of the original resource file included in the page layout file can be, for example, the file name of the original resource file.
  • the page layout file of page 1 includes the following code:
  • the page layout file of page 2 includes the following code:
  • the page layout file of page 3 includes the following code:
  • original resource file 1.png and original resource file 4.xml belong to page 1
  • original resource file 2.png and original resource file 5.xml belong to page 2
  • original resource file 6.jaon and original resource file 3.xml belongs to page 3
  • the original resource file 1.png and the original resource file 4.xml can be combined into one file
  • the original resource file 2.png and the original resource file 5.xml can be combined into one file
  • the original resource file can be combined into one file
  • the file 3.xml is merged with the original resource file 6.jaon into one file.
  • the original resource file 1.png and the original resource file 4.xml can be placed in a merged file named 1-4.png, and the original resource file 2.png and the original resource file 5 can be placed .xml is placed in the file named 2-5.png, the original resource file 3.xml and the original resource file 6.jaon can be placed in the file named 3-6.xml, the merging process is as shown in Figure 5 (a) as shown in Fig.
  • the first page in the method 200 may correspond to any one of page 1, page 2 and page 3.
  • the first resource file may correspond to 1.png
  • the second resource file may correspond to 4.xml
  • the first file It can correspond to the file generated after merging 1.png and 4.xml
  • the first resource file can correspond to 2.png
  • the second resource file can correspond to 5.xml
  • the first file can correspond to 2.png and 5.png.
  • the file generated after the xml is merged; for page 3, the first resource file may correspond to 3.xml, the second resource file may correspond to 6.jaon, and the first file may correspond to the file generated after merging 3.xml and 6.jaon.
  • the Huawei Game APP can determine the starting position of the second resource file according to the offset of the starting position of the second resource file relative to the starting position of the first file, because the first file only includes the first resource file and the second resource file. resource file, the remaining files from the starting position of the second resource file in the first file can be acquired as the second resource file, and finally the page is displayed according to the first resource file and the second resource file.
  • the length of the first resource file and the length of the second resource file may be recorded when the first file is generated.
  • the Huawei Game APP can obtain the first resource file from the first file according to the length of the first resource file, and finally The page is displayed according to the first resource file and the second resource file.
  • the offset of the starting position of the first resource file relative to the starting position of the first file, and the starting position of the second resource file relative to the first file may be recorded when the first file is generated.
  • the offset of the starting position of the file, the length of the first resource file, and the length of the second resource file may be recorded when the first file is generated.
  • the starting position of the second resource file is not adjacent to the ending position of the first resource file. Instead, there is a gap in the middle, or other data is saved in the middle.
  • it is necessary to compare the ending position of the first resource file with the starting position of the second resource file. The length of the interval between positions is taken into account.
  • the information recorded when the first file is generated may be saved in the first file. It is assumed here that the information recorded when the first information is generated includes the offset of the starting position of the first resource file relative to the starting position of the first file, and the starting position of the second resource file relative to the starting position of the first file. The offset of the location, the length of the first resource file, and the length of the second resource file.
  • the offset of 3.xml in the merged file, the length of 3.xml and the index of 3.xml can be saved as a whole in the merged file of page 3 , save the offset of 6.jaon in the merged file, the length of 6.jaon and the index of 6.jaon as a whole in the merged file of page 3.
  • the index of the original resource file, the offset of the original resource file in the merged file, and the length of the original resource file are stored in the merged file as a whole, so that the electronic device can determine the index of the original resource file in the page display stage.
  • the offset and length corresponding to the original resource file For example, in the page display stage, the electronic device can determine the offset of 1.png in the merged file and the length of 1.png according to ID001 in the merged file.
  • ID004 determines the offset of 4.xml in the merged file and the length of 4.xml.
  • index of the original resource file stored in the merged file may also be other identifiers capable of indicating the original resource file, for example, may be the file name of the original resource file, which is not limited in this embodiment of the present application.
  • the offset of 1.png in the merged file and the length of 1.png can be stored in the index relationship corresponding to the index ID001 of 1.png
  • the offset of 4.xml in the merged file and the length of 4.xml are stored in the index relationship corresponding to the index ID004 of 4.xml.
  • the offset of 2.png in the merged file and the length of 2.png can be stored in the index relationship corresponding to ID002
  • 5.xml can be stored in the index relationship corresponding to ID002.
  • the offset in the merged file and the length of 5.xml are stored in the index relationship corresponding to ID005.
  • ID005 For example, if 3.xml and 6.jaon are in the merged file of page 3, the offset of 3.xml in the merged file and the length of 3.xml can be stored in the index relationship corresponding to ID003, and the offset of 3.xml in the merged file and the length of 3.xml can be stored in the index relationship corresponding to ID003,
  • the offset in the merged file and the length of 6.jaon are stored in the index relationship corresponding to ID006.
  • the resource index file storing the offset of the original resource file in the merged file and the length of the original resource file is shown in (d) of FIG. 5 .
  • the offset of the original resource file in the merged file and the length of the original resource file are stored in the index relationship corresponding to the index of the original resource file, which can be understood as: the offset of the original resource file in the merged file,
  • the length of the original resource file is stored as a whole in the resource index file.
  • each page may include one page layout file, or each page may include two or more page layout files.
  • the page layout file of page 1 may include Include the following code:
  • original resource files of different pages with an associated relationship may also be merged to generate a merged file, and the method will be described below.
  • the packaging tool determines the original resource files belonging to different pages with associated relationships from the original resource files according to the page layout file of the page, and merges the original resource files to generate a merged file.
  • the packaging tool generates a combined file according to the three page layout files of the Huawei game app. These three page layout files correspond to the three pages of the Huawei game APP, which are marked as page 4, page 5, and page 6.
  • the page layout file for page 4 includes the following code:
  • the page layout file of page 6 includes the following code:
  • the pages with an associated relationship can usually be pages that are displayed one after the other after the APP is started.
  • the above-mentioned pages 4 and 5 can be, for example, the welcome page and the home page displayed after the Huawei Game APP is started, respectively, or, the pages with an associated relationship, such as It can be a page determined according to the user's operating habits. For example, after the Huawei game APP is launched, the home page is displayed to the user. According to the user's operating habits, the user usually switches from the home page to the attention page.
  • the above page 4 The and page 5 may be, for example, the home page and the follow page displayed after the Huawei game APP is launched, respectively.
  • the length of the merged file may be considered. inside.
  • the length of the merged file generated by merging 1.png, 4.xml, 7.png, and 8.xml is 120KB. Assuming that the preset threshold value is 64KB, since the length of the merged file is greater than 64KB, you can use
  • the merged file is divided into at least two files that meet the requirements. For example, 1.png and 4.xml can be merged into one file, and 7.png and 8.xml can be merged into one file, that is, the original resource files 1.png, 4.xml, 7.png, and 8.xml are combined into two files, so that the length of the combined file meets the requirements.
  • files of the same format can be merged into the same resource file, for example, 1.png and 7.png can be merged into one file, and 4. xml and 8.xml are combined into one resource file.
  • the method for generating a merged file in the compilation phase is described above.
  • the purpose of merging is to speed up page display after the APP is started.
  • the following describes the method 300 provided by the embodiment of the present application after the APP is started.
  • the user starts the Huawei game APP on the electronic device.
  • the page that the electronic device needs to display to the user may be the home page of the Huawei game APP, and the interface content 101 of the home page is as shown in (a) in FIG. 1; or , the user switches from the home page to the attention page on the interface content 101.
  • the electronic device needs to display the attention page to the user.
  • the interface content 102 of the attention page As shown in (b) of Figure 1.
  • Step 310 Obtain first information according to the resource index file.
  • the resource index file includes index, file name and path information of multiple resource files.
  • the multiple resource files include a first resource file and a second resource file.
  • the first information includes the first resource file.
  • Step 320 Load a first file according to the first information, where the first file is generated by merging the first resource file and the second resource file, and the first resource file and the second resource file belong to the first page.
  • Step 330 Acquire the first resource file and the second resource file from the first file according to the second information, and the second information is used to extract the first resource file and the second resource file from the first resource file.
  • the following describes the method 300 for loading resources provided by the embodiment of the present application by taking the electronic device displaying the home page, or displaying the home page and the attention page as an example, in different scenarios.
  • the electronic device when displaying the home page, parses the page layout file of the home page, determines that the indexes of the original resource files included in the home page are ID001 and ID004, and then sequentially loads the original resource files corresponding to ID001 and ID004 to display front page.
  • the original resource file corresponding to ID001 is loaded first by the electronic device, since in the compilation stage, the original resource file 1. Therefore, when the original resource file corresponding to ID001 is loaded, the merged file is actually loaded.
  • the electronic device When loading the original resource file corresponding to ID001, the electronic device determines the file name and path information corresponding to ID001 according to the resource index file, where the file name and path information are the file name and path information of the merged file, according to the file name and path information, the electronic device loads the merged file.
  • the loaded content will be released lazily, in other words, after the loading of the merged file is completed, the loaded content will not be released immediately, but will wait until the original resource in the merged file. Only after the file has been read is it possible to release the loaded content.
  • the acquired original resource files can be marked in the merged file. After all the original resources in the merged file are marked, it means that all the original resource files in the merged file have been read, and the merged file can be released at this time. .
  • the original resource file corresponding to ID001 is first loaded by the electronic device.
  • the original resource file 1.png corresponding to ID001, the original resource file 2.png corresponding to ID002, and the original resource file corresponding to ID004 included in the home page are The resource file 4.xml and the original resource file 6.json corresponding to ID006 are combined into one file. Therefore, when the original resource file corresponding to ID001 is loaded, the combined file is actually loaded.
  • the electronic device When loading the original resource file corresponding to ID001, the electronic device determines the file name and path information corresponding to ID001 according to the resource index file, where the file name and path information are the file name and path information of the merged file, according to the file name and path information, the electronic device loads the merged file.
  • the electronic device After completing the loading of the merged file, the electronic device needs to read the original resource file corresponding to ID001 from the merged file. At this time, according to the determined offset of the original resource file corresponding to ID001 in the merged file and the original resource file corresponding to ID001 The length of the resource file, read the original resource file corresponding to ID001 from the merged file, and display the home page according to the original resource file corresponding to ID001.
  • the method of determining the offset of the original resource file corresponding to ID001 in the merged file and the length of the original resource file corresponding to ID001 please refer to the relevant description in method 200, which is not repeated here for brevity.
  • the electronic device When loading the original resource file corresponding to ID002, the electronic device determines the file name and path information corresponding to ID002 according to the resource index file. The determined file name is consistent with the path information.
  • the electronic device loads the original resource file corresponding to ID002, it actually loads the merged file, but since the loading of the merged file has been completed when loading the original resource file corresponding to ID001, so , the electronic device can ignore this loading, directly read the original resource file corresponding to ID002 from the already loaded merged file, and display the home page according to the original resource file corresponding to ID002.
  • the electronic device When loading the original resource file corresponding to ID001, the electronic device determines the file name and path information corresponding to ID001 according to the resource index file, where the file name and path information are the file name and path information of the merged file, according to the file name and path information, the electronic device loads the merged file.
  • the electronic device After completing the loading of the merged file, the electronic device needs to read the original resource file corresponding to ID001 from the merged file. At this time, according to the determined offset of the original resource file corresponding to ID001 in the merged file and the corresponding ID001 The length of the original resource file, read the original resource file corresponding to ID001 from the merged file, and display the home page according to the original resource file corresponding to ID001.
  • the method of determining the offset of the original resource file corresponding to ID001 in the merged file and the length of the original resource file corresponding to ID001 please refer to the relevant description in method 200, which is not repeated here for brevity.
  • the original resource file corresponding to ID005 For the loading process of another original resource file included in the home page, that is, the original resource file corresponding to ID005, please refer to the loading process of the original resource file corresponding to ID004 in scenario 1, or, please refer to the original resource file corresponding to ID002 in scenario 2.
  • the loading process is not repeated here for brevity.
  • the electronic device determines the file name and path information corresponding to ID002 according to the resource index file.
  • the file name and path information determined from the resource index file according to ID002 are the same as
  • the file name determined from the resource index file according to ID001 is consistent with the path information.
  • the loaded content will be released lazily, in other words, the loaded content will not be released immediately after the loading of the merged file is completed, but will wait until the original It is only possible to release the loaded content after all the resource files have been read.
  • the acquired original resource files can be marked in the merged file. After all the original resources in the merged file are marked, it means that all the original resource files in the merged file have been read, and the merged file can be released at this time. .
  • FIG. 11 shows a schematic flowchart of another method 400 provided by this embodiment of the present application.
  • Method 400 includes the following steps.
  • Step 420 determines that the first page includes the first resource file and the second resource file according to the page layout file of the first page.
  • Step 430 Combine the first resource file and the second resource file to generate a first file.
  • Step 440 Obtain first information according to the resource index file.
  • the resource index file includes indexes, file names, and path information of multiple resource files.
  • the multiple resource files include a first resource file and a second resource file.
  • the first information includes the first resource file. A file's path information and file name.
  • Step 450 Load the first file according to the first information.
  • Step 460 Obtain the first resource file and the second resource file from the first file according to the second information, and the second information is used to extract the first resource file and the second resource file from the first resource file.
  • Step 470 the electronic device displays the first page according to the first resource file and the second resource file.
  • steps 410 to 430 please refer to the related description in the method 200, and for the specific implementation of the steps 440 to 470, please refer to the related description in the method 300, which is not repeated here for brevity.
  • an embodiment of the present application also provides a file, where the file includes a resource index file and a first file.
  • the electronic device includes corresponding hardware and/or software modules for executing each function.
  • the present application can be implemented in hardware or in the form of a combination of hardware and computer software in conjunction with the algorithm steps of each example described in conjunction with the embodiments disclosed herein. Whether a function is performed by hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functionality for each particular application in conjunction with the embodiments, but such implementations should not be considered beyond the scope of this application.
  • the electronic device can be divided into functional modules according to the above method examples.
  • each functional module can be divided corresponding to each function, such as a processing module, a display module, etc., or two or more functions can be integrated into one in the processing module.
  • the above-mentioned integrated modules can be implemented in the form of hardware. It should be noted that, the division of modules in this embodiment is schematic, and is only a logical function division, and there may be other division manners in actual implementation.
  • the electronic device provided in this embodiment is used to execute the above method for generating a file, so the same effect as the above implementation method can be achieved.
  • the electronic device may also include a processing module, a storage module and a communication module.
  • the processing module may be used to control and manage the actions of the electronic device.
  • the storage module may be used to support the electronic device to execute stored program codes and data, and the like.
  • the communication module can be used to support the communication between the electronic device and other devices.
  • the processing module may be a processor or a controller. It may implement or execute the various exemplary logical blocks, modules and circuits described in connection with this disclosure.
  • the processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, and the like.
  • the storage module may be a memory.
  • the communication module may specifically be a device that interacts with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, and a Wi-Fi chip.
  • This embodiment also provides a computer program product, which, when the computer program product runs on a computer, causes the computer to execute the above-mentioned relevant steps, so as to realize the method for generating a file in the above-mentioned embodiment.
  • the embodiments of the present application also provide an apparatus, which may specifically be a chip, a component or a module, and the apparatus may include a connected processor and a memory; wherein, the memory is used for storing computer execution instructions, and when the apparatus is running, The processor can execute the computer-executed instructions stored in the memory, so that the chip executes the method for generating a file in each of the foregoing method embodiments.
  • the electronic device, computer storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, for the beneficial effects that can be achieved, reference can be made to the corresponding provided above. The beneficial effects in the method will not be repeated here.
  • the disclosed apparatus and method may be implemented in other manners.
  • the apparatus embodiments described above are only illustrative.
  • the division of modules or units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or May be integrated into another device, or some features may be omitted, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
  • Units described as separate components may or may not be physically separated, and components shown as units may be one physical unit or multiple physical units, that is, may be located in one place, or may be distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium.
  • a readable storage medium including several instructions to make a device (which may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请提供了一种生成文件的方法以及电子设备,在APP的编译阶段,根据APP的各个页面对应的页面布局文件,将属于同一页面的原始资源文件合并为一个文件,使得在页面显示时,当加载原始资源文件时,实际加载的是合并后生成的资源文件,并且从合并后生成的资源文件中依次连续读取原始资源文件,无需在页面显示时对原始资源文件依次加载再进行读取,从而在页面显示时提升读取原始资源文件的速度,进而提升页面的显示速度。

Description

一种生成文件的方法及电子设备
本申请要求于2020年09月18日提交国家知识产权局、申请号为202010991909.3、申请名称为“一种的生成文件的方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及电子技术领域,尤其涉及一种生成文件的方法及电子设备。
背景技术
当用户在安装有APP(Application,APP)的电子设备上启动了该APP后,电子设备的显示屏会显示该APP的相关页面,例如,当用户在电子设备上启动了华为游戏APP后,电子设备显示华为游戏APP的首页。
APP的安装包内通常会包含各类文件,例如,页面布局文件,图片资源文件、媒体资源文件等,其中,页面布局文件可以描述APP的页面所需的所有资源文件。
在APP的启动过程中,操作系统(operating system,OS)根据页面布局文件确定APP将要显示的页面需要的资源文件,加载该资源文件后通过显示屏显示给用户。
对于用户而言,用户启动APP后,相应页面显示的越快,用户的体验越好,因此,加快APP的页面的显示速度是很有必要的。
发明内容
本申请提供一种生成文件的方法与电子设备,在APP的编译阶段对APP的各个页面对应的页面布局文件进行解析,将属于同一页面或具有关联关系的页面的原始资源文件合并为一个文件,使得在页面显示时,当加载原始资源文件时,实际加载的是合并后生成的资源文件,并且从该合并后生成的资源文件中依次连续读取原始资源文件,无需在页面显示时对原始资源文件依次加载再进行读取,从而在页面显示时提升读取原始资源文件的速度,进而提升页面的显示速度。
第一方面,提供一种方法,应用于电子设备,该方法包括:根据资源索引文件,获取第一信息,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括第一资源文件与第二资源文件,所述第一信息包括所述第一文件的路径信息与文件名;根据所述第一信息,加载第一文件,所述第一文件是由所述第一资源文件与所述第二资源文件合并后生成的,所述第一资源文件与所述第二资源文件属于第一页面;根据第二信息,从所述第一文件中获取所述第一资源文件与所述第二资源文件,所述第二信息用于从所述第一资源文件中提取所述第一资源文件与所述第二资源文件;根据所述第一资源文件与所述第二资源文件,所述电子设备显示所述第一页面。
值得一提的是,本申请实施例涉及的加载文件的过程,可以是先将文件从非易失性存储器中读取出来,再将读取到的文件存储到随机存取存储器的过程。例如,对于第一文件,加载第一文件时,可以将第一文件从非易失性存储器中读取出来,再将第一文件存储到随机存取存储器。
基于上述技术方案,在APP的编译阶段,根据APP的各个页面对应的页面布局文件, 将属于同一页面的原始资源文件合并为一个文件,使得在页面显示时,当加载原始资源文件时,实际加载的是合并后生成的资源文件,例如,加载合并后生成的资源文件时,将合并后生成的资源文件从非易失性存储器中读取出来,再将合并后生成的资源文件存储到随机存取存储器,使得可以从合并后生成的资源文件中依次连续读取原始资源文件,无需在页面显示时对原始资源文件依次加载再进行读取,从而在页面显示时提升读取原始资源文件的速度,进而提升页面的显示速度。
需要说明的是,本申请实施例提供的方法并不限定页面所包括的原始资源文件的数量,换句话说,本申请实施例提供的方法同样适用于一个页面包括多个原始资源文件的情况。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,所述第二信息包括所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量。
基于上述技术方案,在进行页面显示时,使得电子设备能够根据第二信息确定第一资源文件在第一文件中的位置与第一资源文件的长度,并且确定第二资源文件在第一文件中的位置与第二资源文件的长度,根据该位置以及长度,依次从第一文件中获取第一资源文件与第二资源文件,从而根据第一资源文件与第二资源文件显示第一页面。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,所述第二信息包括所述第一资源文件的长度与所述第二资源文件的长度。
基于上述技术方案,在进行页面显示时,使得电子设备能够根据第二信息确定第一资源文件在第一文件中的位置与第一资源文件的长度,并且确定第二资源文件在第一文件中的位置与第二资源文件的长度,根据该位置以及长度,依次从第一文件中获取第一资源文件与第二资源文件,从而根据第一资源文件与第二资源文件显示第一页面。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,所述第二信息保存在所述第一文件或所述资源索引文件中。
基于上述技术方案,通过将第二信息保存在第一文件或资源索引文件中,使得在显示页面时,电子设备能够较为快速地获取到第二信息,并根据第二信息从第一文件中获取第一资源文件与第二资源文件,从而提高根据第一资源文件与第二资源文件显示第一页面的速度。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,所述第一资源文件与所述第二资源文件的类型相同。
结合第一方面和上述实现方式,在第一方面的某些实现方式中,所述第一文件的长度小于或等于预设阈值。
基于上述技术方案,由于合并后生成的资源文件的大小会对加载速度产生影响,因此,通过限定合并后生成的资源文件的长度,例如,限定第一文件的长度小于或等于预设阈值,从而提升显示速度。
第二方面,提供一种生成文件的方法,所述方法包括:获取第一页面的页面布局文件;根据第一页面的页面布局文件,确定所述第一页面包括第一资源文件与第二资源文件;对所述第一资源文件与所述第二资源文件进行合并,生成第一文件。
值得一提的是,本申请实施例涉及的加载文件的过程,可以是先将文件从非易失性存 储器中读取出来,再将读取到的文件存储到随机存取存储器的过程。例如,对于第一文件,加载第一文件时,可以将第一文件从非易失性存储器中读取出来,再将第一文件存储到随机存取存储器。
基于上述技术方案,在APP的编译阶段,根据APP的各个页面对应的页面布局文件,将属于同一页面的原始资源文件合并为一个文件,使得在页面显示时,当加载原始资源文件时,实际加载的是合并后生成的资源文件,例如,加载合并后生成的资源文件时,将合并后生成的资源文件从非易失性存储器中读取出来,再将合并后生成的资源文件存储到随机存取存储器,使得可以从合并后生成的资源文件中依次连续读取原始资源文件,无需在页面显示时对原始资源文件依次加载再进行读取,从而在页面显示时提升读取原始资源文件的速度,进而提升页面的显示速度。
需要说明的是,本申请实施例提供的生成文件的方法并不限定页面所包括的原始资源文件的数量,换句话说,本申请实施例提供的生成文件的方法同样适用于一个页面包括多个原始资源文件的情况。
结合第二方面,在第二方面的某些实现方式中,所述根据所述第一页面的页面布局文件,确定所述第一页面包括第一资源文件与第二资源文件,包括:根据所述第一页面的页面布局文件中包括的所述第一资源文件的标识与所述第二资源文件的标识,确定所述第一资源文件与所述第二资源文件属于所述第一页面。
结合第二方面,在第二方面的某些实现方式中,所述第一文件中存储有所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量,和/或,所述第一文件中存储有所述第一资源文件的长度与所述第二资源文件的长度。
基于上述技术方案,在进行页面显示时,使得电子设备能够根据第二信息确定第一资源文件在第一文件中的位置与第一资源文件的长度,并且确定第二资源文件在第一文件中的位置与第二资源文件的长度,根据该位置以及长度,依次从第一文件中获取第一资源文件与第二资源文件,从而根据第一资源文件与第二资源文件显示第一页面。
结合第二方面,在第二方面的某些实现方式中,所述方法还包括:生成资源索引文件,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括所述第一资源文件与所述第二资源文件。
结合第二方面,在第二方面的某些实现方式中,所述资源索引文件中存储有所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量,和/或,所述第一文件中存储有所述第一资源文件的长度与所述第二资源文件的长度。
结合第二方面和上述实现方式,在第二方面的某些实现方式中,所述第一资源文件与所述第二资源文件是根据所述第一页面的至少一个页面布局文件确定的。
结合第二方面和上述实现方式,在第二方面的某些实现方式中,所述第一资源文件与所述第二资源文件的类型相同。
结合第二方面和上述实现方式,在第二方面的某些实现方式中,所述第一文件的长度小于或等于预设阈值。
基于上述技术方案,由于合并后生成的资源文件的大小会对加载速度产生影响,因此, 通过限定合并后生成的资源文件的长度,例如,限定第一文件的长度小于或等于预设阈值,从而加快显示速度。
第三方面,提供一种方法,应用于包括显示屏的电子设备,其特征在于,所述方法包括:获取第一页面的页面布局文件;根据第一页面的至少一个页面布局文件,确定所述第一页面包括第一资源文件与第二资源文件;对所述第一资源文件与所述第二资源文件进行合并,生成第一文件;根据资源索引文件,获取第一信息,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括所述第一资源文件与所述第二资源文件,所述第一信息包括所述第一文件的路径信息与文件名;根据所述第一信息,加载所述第一文件;根据第一信息,加载所述第一文件;根据第二信息,从所述第一文件中获取所述第一资源文件与所述第二资源文件,所述第二信息用于从所述第一资源文件中提取所述第一资源文件与所述第二资源文件;根据所述第一资源文件与所述第二资源文件,所述电子设备显示所述第一页面。
值得一提的是,本申请实施例涉及的加载文件的过程,可以是先将文件从非易失性存储器中读取出来,再将读取到的文件存储到随机存取存储器的过程。例如,对于第一文件,加载第一文件时,可以将第一文件从非易失性存储器中读取出来,再将第一文件存储到随机存取存储器。
基于上述技术方案,在APP的编译阶段,根据APP的各个页面对应的页面布局文件,将属于同一页面的原始资源文件合并为一个文件,使得在页面显示时,当加载原始资源文件时,实际加载的是合并后生成的资源文件,例如,加载合并后生成的资源文件时,将合并后生成的资源文件从非易失性存储器中读取出来,再将合并后生成的资源文件存储到随机存取存储器,使得可以从合并后生成的资源文件中依次连续读取原始资源文件,无需在页面显示时对原始资源文件依次加载再进行读取,从而在页面显示时提升读取原始资源文件的速度,进而提升页面的显示速度。
需要说明的是,本申请实施例提供的方法并不限定页面所包括的原始资源文件的数量,换句话说,本申请实施例提供的方法同样适用于一个页面包括多个原始资源文件的情况。
第四方面,提供一种文件,包括根据第二方面中生成文件的方法生成的第一文件,和/或,包括根据第二方面中生成文件的方法生成的资源索引文件。
第五方面,提供一种电子设备,包括显示屏,存储器,一个或多个处理器,以及一个或多个程序;其中所述一个或多个程序被存储在所述存储器中;所述一个或多个处理器在执行所述一个或多个程序时,使得所述电子设备执行上述任一方面任一项可能的实现中的方法。
第六方面,提供一种电子设备,包括存储器,一个或多个处理器,以及一个或多个程序;其中所述一个或多个程序被存储在所述存储器中;所述一个或多个处理器在执行所述一个或多个程序时,使得所述电子设备执行上述任一方面任一项可能的实现中的生成文件的方法。
第七方面,提供一种装置,包括处理模块与显示模块,处理模块用于根据资源索引文件,获取第一信息,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括第一资源文件与第二资源文件,所述第一信息包括所述第一文件的路 径信息与文件名;处理模块还用于根据所述第一信息,加载第一文件,所述第一文件是由所述第一资源文件与所述第二资源文件合并后生成的,所述第一资源文件与所述第二资源文件属于第一页面;处理模块还用于根据第二信息,从所述第一文件中获取所述第一资源文件与所述第二资源文件,所述第二信息用于从所述第一资源文件中提取所述第一资源文件与所述第二资源文件;显示模块用于根据所述第一资源文件与所述第二资源文件,显示所述第一页面。
结合第七方面和上述实现方式,在第七方面的某些实现方式中,所述第二信息包括所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量。
结合第七方面和上述实现方式,在第七方面的某些实现方式中,所述第二信息包括所述第一资源文件的长度与所述第二资源文件的长度。
结合第七方面和上述实现方式,在第七方面的某些实现方式中,所述第二信息保存在所述第一文件或所述资源索引文件中。
结合第七方面和上述实现方式,在第七方面的某些实现方式中,所述第一资源文件与所述第二资源文件的类型相同。
结合第七方面和上述实现方式,在第七方面的某些实现方式中,所述第一文件的长度小于或等于预设阈值。
第八方面,提供一种装置,包括处理模块,处理模块用于获取第一页面的页面布局文件;处理模块还用于根据第一页面的页面布局文件,确定所述第一页面包括第一资源文件与第二资源文件;处理模块还用于对所述第一资源文件与所述第二资源文件进行合并,生成第一文件。
结合第八方面和上述实现方式,在第八方面的某些实现方式中,处理模块还用于根据所述第一页面的页面布局文件中包括的所述第一资源文件的标识与所述第二资源文件的标识,确定所述第一资源文件与所述第二资源文件属于所述第一页面。
结合第八方面和上述实现方式,在第八方面的某些实现方式中,所述第一文件中存储有所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量,和/或,所述第一文件中存储有所述第一资源文件的长度与所述第二资源文件的长度。
结合第八方面和上述实现方式,在第八方面的某些实现方式中,处理模块还用于生成资源索引文件,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括所述第一资源文件与所述第二资源文件。
结合第八方面和上述实现方式,在第八方面的某些实现方式中,所述资源索引文件中存储有所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量,和/或,所述第一文件中存储有所述第一资源文件的长度与所述第二资源文件的长度。
结合第八方面和上述实现方式,在第八方面的某些实现方式中,所述第一资源文件与所述第二资源文件是根据所述第一页面的至少一个页面布局文件确定的。
结合第八方面和上述实现方式,在第八方面的某些实现方式中,所述第一资源文件与所述第二资源文件的类型相同。
结合第八方面和上述实现方式,在第八方面的某些实现方式中,所述第一文件的长度小于或等于预设阈值。
第九方面,提供一种装置,处理模块与显示模块,处理模块用于获取第一页面的页面布局文件;处理模块还用于根据第一页面的至少一个页面布局文件,确定所述第一页面包括第一资源文件与第二资源文件,所述第一信息包括所述第一文件的路径信息与文件名;处理模块还用于对所述第一资源文件与所述第二资源文件进行合并,生成第一文件;处理模块还用于根据资源索引文件,获取第一信息,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括所述第一资源文件与所述第二资源文件;处理模块还用于根据所述第一信息,加载所述第一文件;处理模块还用于根据第一信息,加载所述第一文件;处理模块还用于根据第二信息,从所述第一文件中获取所述第一资源文件与所述第二资源文件,所述第二信息用于从所述第一资源文件中提取所述第一资源文件与所述第二资源文件;显示模块用于根据所述第一资源文件与所述第二资源文件,显示所述第一页面。
第十方面,本申请提供了一种计算机存储介质,包括计算机指令,当计算机指令在电子设备上运行时,使得电子设备执行上述任一方面任一项可能的方法。
第十一方面,本申请提供了一种计算机存储介质,包括计算机指令,当计算机指令在电子设备上运行时,使得电子设备执行上述任一方面任一项可能的生成文件的方法。
第十二方面,本申请提供了一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行上述任一方面任一项可能的方法。
第十三方面,本申请提供了一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行上述任一方面任一项可能的生成文件的方法。
附图说明
图1是本申请实施例提供的界面示意图;
图2是本申请实施例提供的一例电子设备的结构示意图;
图3中的(a)图是本申请实施例提供的生成文件的方法的一种应用场景的示意图;
图3中的(b)图是本申请实施例提供的生成文件的方法的又一种应用场景的示意图;
图3中的(c)图是本申请实施例提供的生成文件的方法的再一种应用场景的示意图;
图3中的(d)图是本申请实施例提供的生成文件的方法的再一种应用场景的示意图;
图4是本申请实施例提供的生成文件的方法的示意性流程图;
图5中的(a)图是本申请实施例提供的原始资源文件的合并过程的示意图;
图5中的(b)图是本申请实施例提供的合并文件的示意图;
图5中的(c)图是本申请实施例提供的资源索引文件的一例示意图;
图5中的(d)图是本申请实施例提供的资源索引文件的另一例示意图;
图6是本申请实施例提供的原始资源文件的另一例合并过程的示意图;
图7是本申请实施例提供的方法的示意性流程图;
图8是本申请实施例提供的原始资源文件的一例加载过程的示意图;
图9是本申请实施例提供的原始资源文件的另一例加载过程的示意图;
图10是本申请实施例提供的原始资源文件的再一例加载过程的示意图;
图11是本申请实施例提供的方法的另一示意性流程图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,在本申请实施例的描述中,“多个”是指两个或多于两个。
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,例如本申请实施例中描述的“第一资源文件”、“第二资源文件”。
本申请实施例提供了一种生成文件的方法,在APP的编译阶段对APP的各个页面对应的页面布局文件进行解析,将属于同一页面的原始资源文件合并为一个文件,使得在页面显示时,当加载原始资源文件时,实际加载的是合并文件,并且从该合并文件中依次获取原始资源文件,无需在页面显示时对原始资源文件依次进行加载,从而在页面显示时减少加载资源文件的次数,提高页面的显示速度。在本申请实施例中,将合并前的资源文件称为原始资源文件,将对原始资源文件合并后生成的资源文件称为合并文件。
本申请实施例提供了一种方法,在页面显示时,通过加载合并文件,并且从该合并文件中依次获取原始资源文件,无需在页面显示时对原始资源文件依次进行加载,从而在页面显示时减少加载原始资源文件的次数,提高页面的显示速度。
本申请实施例提供的生成文件的方法与方法可以应用于增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、手机、平板电脑、可穿戴设备、车载设备、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)等电子设备上。本申请实施例对电子设备的具体类型不作任何限制。
在介绍本申请实施例的方法之前,先介绍几个相关概念。
APP的页面
APP的页面可以理解为电子设备检测到用户启动APP的操作时,响应于该操作,电子设备的显示界面所显示的内容,或者,也可以是APP被启动后,电子设备检测到用户切换页面的操作时,响应于该操作,电子设备的显示界面所显示的内容。
例如,当APP为华为游戏APP时,APP的页面可以理解为电子设备检测到用户启动华为游戏APP的操作时,响应于该操作,电子设备的显示界面所显示的华为游戏APP的首页,首页的界面内容101如图1中的(a)图所示,或者,也可以是华为游戏APP被启动后,电子设备检测到用户由首页切换至关注页面的操作时,响应于该操作,电子设备所显示的关注页面,关注页面的界面内容102如图1中的(b)图所示。
APP的页面布局文件与APP的资源文件
页面布局文件与原始资源文件均为开发者在APP的开发过程中的引入的文件,页面布局文件用于描述该APP的各个页面的显示所需的各类原始资源文件,其中,每个页面对应一个页面布局文件,电子设备在显示相应页面时,通过解析页面布局文件,确定当前页面的显示包括的原始资源文件,获取相应原始资源文件并将该原始资源文件通过电子设 备的显示屏显示在页面的相应位置。
原始资源文件例如可以是APP的页面中包括的图片、文本等。
资源索引文件
APP开发完成之后,在APP的编译阶段,可以针对APP所引用的原始资源文件,生成原始资源文件索引,将页面布局文件中引用的原始资源文件的文件名替换为原始资源文件的索引,根据原始资源文件的索引、文件名以及路径信息生成资源索引文件。
需要说明的是,在本申请实施例中,资源索引文件中保存的是合并文件的文件名以及合并文件的路径信息。例如,将1.png与4.xml合并后,生成合并文件1-4.png,此时1.png与4.xml的文件名均是合并文件的文件名,因此,1.png的索引在资源索引文件中对应的文件名与4.xml的索引在资源索引文件中对应的文件名是一致的,1.png的索引在资源索引文件中对应的路径信息与4.xml的索引在资源索引文件中对应的路径信息是一致的。
此外,还可以针对页面布局文件生成索引,根据页面布局文件的索引、页面布局文件的文件名以及页面布局文件的路径信息生成资源索引文件。应理解,针对页面布局文件生成的资源索引文件与针对资源文件生成的资源索引文件可以是同一个文件,或者,也可以是不同的文件,本申请实施例对此不作限定。
例如,当APP为华为游戏APP时,电子设备在显示华为游戏APP的首页时,根据获取到的页面布局文件的索引,在页面布局文件的资源索引文件中确定首页的页面布局文件的文件名以及路径信息,进而获取页面布局文件,根据首页对应的页面布局文件,确定首页的包括的资源文件的索引,根据该索引在资源索引文件中找到合并文件的文件名以及路径信息,进而获取合并文件,最终根据从合并文件中获取的原始资源文件完成首页的显示。
示例性的,图2是是本申请实施例提供的一例电子设备100的结构示意图。电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个 或多个处理器中。
其中,控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。UART接口是一种通用串行数据总线,用于异步通信。MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。
GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用 上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,外部存储器,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),MiniLED,MicroLED,Micro-OLED,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。视频编解码器用于对数字视频压缩或解压缩。NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等 应用,例如:图像识别,人脸识别,语音识别,文本理解等。
内部存储器121可以包括一个或多个随机存取存储器(random access memory,RAM)和一个或多个非易失性存储器(non-volatile memory,NVM)。
随机存取存储器可以包括静态随机存储器(static random-access memory,SRAM)、动态随机存储器(dynamic random access memory,DRAM)、同步动态随机存储器(synchronous dynamic random access memory,SDRAM)、双倍资料率同步动态随机存取存储器(double data rate synchronous dynamic random access memory,DDR SDRAM,例如第五代DDR SDRAM一般称为DDR5SDRAM)等。
非易失性存储器可以包括磁盘存储器件、快闪存储器(flash memory)。
快闪存储器按照运作原理划分可以包括NOR FLASH、NAND FLASH、3D NAND FLASH等,按照存储单元电位阶数划分可以包括单阶存储单元(single-level cell,SLC)、多阶存储单元(multi-level cell,MLC)、三阶储存单元(triple-level cell,TLC)、四阶储存单元(quad-level cell,QLC)等,按照存储规范划分可以包括通用闪存存储(英文:universal flash storage,UFS)、嵌入式多媒体存储卡(embedded multi media Card,eMMC)等。
随机存取存储器可以由处理器110直接进行读写,可以用于存储操作系统或其他正在运行中的程序的可执行程序(例如机器指令),还可以用于存储用户及应用程序的数据等。
非易失性存储器也可以存储可执行程序和存储用户及应用程序的数据等,可以提前加载到随机存取存储器中,用于处理器110直接进行读写。外部存储器接口120可以用于连接外部的非易失性存储器,实现扩展电子设备100的存储能力。外部的非易失性存储器通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部的非易失性存储器中。
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。电子设备100的按键190可以包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。SIM卡接口195用于连接SIM卡。
此外,电子设备100还包括各种不同传感器,例如,压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。陀螺仪传感器180B可以用于确定电子设备100的运动姿态。气压传感器180C用于测量气压。磁传感器180D包括霍尔传感器。加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。距离传感器180F,用于测量距离。电子设备100可以通过红外或激光测量距离。在一些实施例中,拍摄场景,电子设备100可以利用距离传感器180F测距以实现快速对焦。接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。环境光传感器180L用于感知环境光亮度。电子设备100可以根据感知的环境光亮度自适应调节显示屏194亮度。指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。触摸传感器180K,也称“触控面板”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测 到的触摸操作传递给应用处理器,以确定触摸事件类型。骨传导传感器180M可以获取振动信号。
本申请以下实施例将以具有图2所示结构的电子设备为例,且以华为游戏APP为例,对本申请实施例提供的生成文件的方法与方法进行具体阐述。
首先对生成文件的方法200的应用场景进行介绍。
一种应用场景如图3中的(a)图所示,在华为游戏APP的编译阶段,开发人员可以使用打包工具,由打包工具根据方法200对华为游戏APP引用的原始资源文件进行合并,之后将编译后生成的华为游戏APP的可执行文件上传至应用服务器,用户可以从应用服务器将华为游戏APP下载至电子设备;另一种应用场景如图3中的(b)图所示,在将华为游戏APP的原始代码上传至应用服务器之后,由应用服务器对华为游戏APP的原始代码进行编译,在编译阶段根据方法200对华为游戏APP中的原始资源文件进行合并,最终生成华为游戏APP的可执行文件,用户可以从应用服务器将华为游戏APP下载至电子设备;再一种应用场景如图3中的(c)图所示,开发人员对华为游戏APP的原始代码完成编译之后,将编译后生成的华为游戏APP的可执行文件上传至服务器,由服务器根据方法200对华为游戏APP中的原始资源文件进行合并,用户可以从应用服务器将华为游戏APP下载至电子设备;再一种应用场景如图3中的(d)图所示,当用户从应用服务器将华为游戏APP下载至电子设备后,由电子设备根据方法200对华为游戏APP中的原始资源文件进行合并。本申请实施例对此不作限定。
下面以图3中的(a)图所示的应用场景为例,对生成文件的方法200进行介绍。图4示出了生成文件的方法200的示意性流程图。方法200包括以下步骤。
步骤210,获取第一页面的页面布局文件。
步骤220,根据第一页面的页面布局文件,确定第一页面包括第一资源文件与第二资源文件。
步骤230,对第一资源文件与第二资源文件进行合并,生成第一文件。
在华为游戏APP的编译阶段,打包工具根据华为游戏APP的各个页面对应的页面布局文件,从华为游戏APP的所有原始资源文件中确定出属于同一页面的原始资源文件,对属于同一页面的原始资源文件进行合并,生成合并文件。
例如,在华为游戏APP的编译阶段,打包工具分别根据华为游戏APP的三个页面布局文件中包括的原始资源文件的标识,生成合并文件。这三个页面布局文件分别对应华为游戏APP的三个页面,记为页面1、页面2与页面3。
页面布局文件中包括的原始资源文件的标识例如可以是原始资源文件的文件名,例如,页面1的页面布局文件中包括如下代码:
Resource1=“1.png/”
Resource2=“4.xml/”
页面2的页面布局文件中包括如下代码:
Resource3=“2.png/”
Resource4=“5.xml/”
页面3的页面布局文件中包括如下代码:
Resource5=“6.jaon/”
Resource6=“3.xml/”
根据上述代码,可以确定原始资源文件1.png与原始资源文件4.xml属于页面1,原始资源文件2.png与原始资源文件5.xml属于页面2,原始资源文件6.jaon与原始资源文件3.xml属于页面3,可以将原始资源文件1.png与原始资源文件4.xml合并为一个文件,将原始资源文件2.png与原始资源文件5.xml合并为一个文件,可以将原始资源文件3.xml与原始资源文件6.jaon合并为一个文件。例如,在合并原始资源文件时,可以将原始资源文件1.png与原始资源文件4.xml放在命名为1-4.png合并文件中,可以将原始资源文件2.png与原始资源文件5.xml放在命名为2-5.png的文件中,可以将原始资源文件3.xml与原始资源文件6.jaon放在命名为3-6.xml的文件中,合并过程如图5中的(a)图所示。
方法200中的第一页面可以对应页面1、页面2与页面3中的任意一种,对于页面1,第一资源文件可以对应1.png,第二资源文件可以对应4.xml,第一文件可以对应1.png与4.xml合并后生成的文件;对于页面2,第一资源文件可以对应2.png,第二资源文件可以对应5.xml,第一文件可以对应2.png与5.xml合并后生成的文件;对于页面3,第一资源文件可以对应3.xml,第二资源文件可以对应6.jaon,第一文件可以对应3.xml与6.jaon合并后生成的文件。
在将第一资源文件与第二资源文件合并为第一文件后,为了使得显示页面时能够在第一文件中准确找到第一资源文件与第二资源文件,就需要知道第一资源文件的起始位置相对于第一文件的起始位置的偏移量(offset)以及第一资源文件的长度(length),并且需要知道第二资源文件的起始位置相对于第一文件的起始位置的偏移量以及第二资源文件的长度。
为了达到该目的,在一种实现方式中,可以在生成第一文件时记录第一资源文件的起始位置相对于第一文件的起始位置的偏移量与第二资源文件的起始位置相对于第一文件的起始位置的偏移量。需要说明的是,以下是基于第一资源文件的起始位置相对于第一文件的起始位置的偏移量小于第二资源文件的起始位置相对于第一文件的起始位置的偏移量进行描述的。换句话说,在生成第一文件时,可以将第一资源文件先放在第一文件中,再将第二资源文件追加在第一资源文件的后面。
假设用户在电子设备上安装了华为游戏APP,在进行页面显示时,华为游戏APP可以根据第一资源文件的起始位置相对于第一文件的起始位置的偏移量,确定第一资源文件的起始位置,根据第一资源文件的起始位置相对于第一文件的起始位置的偏移量与第二资源文件的起始位置相对于第一文件的起始位置的偏移量的差值,确定第一资源文件的长度,从而从第一文件中获取第一资源文件。
华为游戏APP可以根据第二资源文件的起始位置相对于第一文件的起始位置的偏移量,确定第二资源文件的起始位置,由于第一文件仅包括第一资源文件与第二资源文件,则可以在第一文件中将从第二资源文件的起始位置起的剩余文件均作为第二资源文件进行获取,最终根据第一资源文件与第二资源文件进行页面的显示。
在另一种实现方式中,可以在生成第一文件时记录第一资源文件的长度与第二资源文件的长度。
假设用户在电子设备上安装了华为游戏APP,在进行页面显示时,华为游戏APP可以根据第一资源文件的长度,确定第二资源文件的起始位置,并结合第二资源文件的长度, 从第一文件中获取第一资源文件。
假设第一资源文件的起始位置相对于第一文件的起始位置的偏移量为0,则华为游戏APP可以根据第一资源文件的长度,从第一文件中获取第一资源文件,最终根据第一资源文件与第二资源文件进行页面的显示。
在再一种实现方式中,可以在生成第一文件时记录第一资源文件的起始位置相对于第一文件的起始位置的偏移量、第二资源文件的起始位置相对于第一文件的起始位置的偏移量、第一资源文件的长度以及第二资源文件的长度。
需要说明的是,在对原始资源文件进行合并时,两个原始资源文件之间可以存在空隙,换句话说,第二资源文件的起始位置与第一资源文件的终止位置并不相邻,而是中间存在空隙,或者,中间保存了其他数据,此时在根据第一资源文件的长度确定第二资源文件的起始位置相对于第一文件的起始位置的偏移量时,则需要将第一资源文件的终止位置与第二资源文件的起始位置之间间隔的长度考虑在内,或者,在根据第一资源文件的起始位置相对于第一文件的起始位置的偏移量与第二资源文件的起始位置相对于第一文件的起始位置的偏移量,确定第一资源文件的长度时,需要将第一资源文件的终止位置与第二资源文件的起始位置之间间隔的长度考虑在内。
可选地,可以将生成第一文件时记录的信息保存在第一文件中。此处假设生成第一信息时记录的信息包括第一资源文件的起始位置相对于第一文件的起始位置的偏移量、第二资源文件的起始位置相对于第一文件的起始位置的偏移量、第一资源文件的长度以及第二资源文件的长度。
例如,如图5中的(b)图所示,1.png与4.xml在页面1的合并文件中,可以将1.png在合并文件中的偏移量、1.png的长度与1.png的索引作为一个整体保存在页面1的合并文件中,将4.xml在合并文件中的偏移量、1.png的长度与1.png的索引保存在页面1的合并文件中。
2.png、5.xml在页面2的合并文件中,可以将2.png在合并文件中的偏移量、2.png的长度与2.png的索引作为一个整体保存在页面2的合并文件中,将5.xml在合并文件中的偏移量、5.xml的长度与5.xml的索引作为一个整体保存在页面2的合并文件中。
3.xml、6.jaon在页面3的合并文件中,可以将3.xml在合并文件中的偏移量、3.xml的长度与3.xml的索引作为一个整体保存在页面3的合并文件中,将6.jaon在合并文件中的偏移量、6.jaon的长度与6.jaon的索引作为一个整体保存在页面3的合并文件中。
将原始资源文件的索引与原始资源文件在合并文件中的偏移量、原始资源文件的长度作为一个整体的保存在合并文件中,是为了在页面显示阶段电子设备能够根据原始资源文件的索引确定与原始资源文件相对应的偏移量与长度,例如,在页面显示阶段,电子设备在合并文件中可以根据ID001确定1.png在合并文件中的偏移量以及1.png的长度,可以根据ID004确定4.xml在合并文件中的偏移量以及4.xml的长度。
需要说明的是,上述保存在合并文件中的原始资源文件的索引也可以是其他能够指示原始资源文件的标识,例如,可以是原始资源文件的文件名,本申请实施例对此不做限定。
可选地,可以将生成第一文件时记录的信息保存在资源索引文件中。此处假设生成第一信息时记录的信息包括第一资源文件的起始位置相对于第一文件的起始位置的偏移量、第二资源文件的起始位置相对于第一文件的起始位置的偏移量、第一资源文件的长度以及 第二资源文件的长度。
假设华为游戏APP引用的原始资源文件包括1.png、2.png、3.png、4.xml、5.xml、6.jaon,在编译阶段,为1.png、2.png、3.png、4.xml、5.xml、6.jaon生成的资源索引文件如图5中的(c)图所示,其中,图5中的(c)图中ID001、ID002、ID003、ID004、ID005、ID006是分别为1.png、2.png、3.png、4.xml、5.xml、6.jaon生成的索引,需要说明的是,图5中的(c)图中未示出每个合并文件的文件名以及路径信息。
例如,1.png与4.xml在页面1的合并文件中,可以将1.png在合并文件中的偏移量与1.png的长度保存在1.png的索引ID001对应的索引关系中,将4.xml在合并文件中的偏移量与4.xml的长度保存在4.xml的索引ID004对应的索引关系中。例如,2.png、5.xml在页面2的合并文件中,可以将2.png在合并文件中的偏移量与2.png的长度保存在ID002对应的索引关系中,将5.xml在合并文件中的偏移量与5.xml的长度保存在ID005对应的索引关系中。例如,3.xml、6.jaon在页面3的合并文件中,可以将3.xml在合并文件中的偏移量与3.xml的长度保存在ID003对应的索引关系中,将在6.jaon合并文件中的偏移量与6.jaon的长度保存在ID006对应的索引关系中。其中,保存有原始资源文件在合并文件中的偏移量、原始资源文件的长度的资源索引文件如图5中的(d)图所示。
其中,将原始资源文件在合并文件中的偏移量、原始资源文件的长度保存在原始资源文件的索引对应的索引关系中,可以理解为:将原始资源文件在合并文件中的偏移量、原始资源文件的长度作为一个整体保存在资源索引文件中。
需要说明的是,在具体实现时,每个页面可以包括一个页面布局文件,或者,每个页面可以包括两个或者多个页面布局文件,例如,对于页面1,页面1的页面布局文件中可以包括如下代码:
Resource1=“1.png/”
Include=“1”
根据上述代码,可以确定原始资源文件1.png属于页面1,还可以确定页面1还包括索引为1的页面布局文件,因此,可以进一步根据索引为1的页面布局文件,确定页面1包括的其他原始资源文件。例如,索引为1的页面布局文件包括如下代码:
Resource2=“4.xml/”
根据上述代码,可以确定原始资源文件4.xml也属于页面1,因此,可以将原始资源文件1.png与原始资源文件4.xml合并为一个文件。
需要说明的是,上述仅以某一个页面包括两个原始资源文件为例,对方法200进行了说明,但本申请实施例并不限定页面所包括的原始资源文件的数量,方法200同样适用于一个页面包括多个原始资源文件的情况。
在本申请实施例中,还可以对具有关联关系的不同页面的原始资源文件进行合并,生成合并文件,下面对该方法进行说明。
在华为游戏APP的编译阶段,打包工具根据页面的页面布局文件,从原始资源文件中确定出属于具有关联关系的不同页面的原始资源文件,将该原始资源文件合并后生成一个合并文件。
例如,在华为游戏APP的编译阶段,打包工具分别根据华为游戏APP的三个页面布局文件,生成合并文件。这三个页面布局文件分别对应华为游戏APP的三个页面,记为 页面4、页面5与页面6。
例如,页面4的页面布局文件中包括如下代码:
Related=“5”
Resource7=“1.png/”
Resource8=“5.xml/”
页面5的页面布局文件中包括如下代码:
Related=“4”
Resource9=“2.png/”
Resource10=“6.jaon/”
页面6的页面布局文件中包括如下代码:
Resource11=“3.png/”
Resource12=“4.xml/”
根据上述代码,可以确定页面4与页面5是存在关联关系的页面,并且确定原始资源文件1.png与原始资源文件5.xml属于页面4,原始资源文件2.png与原始资源文件6.jaon属于页面5,原始资源文件3.png与原始资源文件4.xml属于页面6。
因此,在对原始资源文件进行合并时,可以将原始资源文件1.png、原始资源文件5.xml、原始资源文件2.png与原始资源文件6.jaon合并为一个文件,将原始资源文件3.png与原始资源文件4.xml合并为一个文件。例如,在合并资源文件时,可以将原始资源文件1.png、原始资源文件5.xml、原始资源文件2.png与原始资源文件6.jaon放在命名为1-2-5-6.png的文件中,合并过程如图6所示。
其中,具有关联关系的页面通常可以是APP启动后接连显示的页面,例如,上述页面4与页面5例如可以分别是华为游戏APP启动后显示的欢迎页与首页,或者,具有关联关系的页面例如可以是根据用户的操作习惯确定的页面,例如,华为游戏APP启动后向用户显示的是首页,根据用户的操作习惯,用户通常会进行从首页切换至关注页面的操作,此时,上述页面4与页面5例如可以分别是华为游戏APP启动后显示的首页与关注页面。
为了加快电子设备的显示速度,可以在页面4的页面布局文件中通过Related=“5”声明页面4与页面5存在关联关系,在页面5的页面布局文件中通过Related=“4”声明页面5与页面4存在关联关系,使得在编译阶段,打包工具可以根据页面4与页面5的页面布局文件,确定页面4与页面5存在关联关系,并将这两个页面的页面布局文件中引用的原始资源文件合并为一个文件。
需要说明的是,方法200中的其他描述同样适用于该方法,具体请参考方法200中的相关描述,为了简洁,此处不再赘述。
在本申请实施例中,对于需要将多个原始资源文件进行合并,生成一个合并文件的情况,由于合并文件的大小对加载速度产生影响,在生成合并文件时,可以将合并文件的长度因素考虑在内。
例如,可以规定合并文件的长度小于或等于预设阈值,如果合并文件的长度大于预设阈值,则可以将合并文件拆分为至少两个文件,以使合并文件的长度满足要求。
例如,将1.png、4.xml、7.png、8.xml合并后生成的合并文件的长度为120KB,假设 预设阈值的取值为64KB,由于合并后文件的长度大于64KB,可以将合并文件拆分为满足要求的至少两个文件,例如,可以将1.png与4.xml合并为一个文件,将7.png、8.xml合并为一个文件,即将原始资源文件1.png、4.xml、7.png、8.xml合并为两个文件,以使合并文件的长度满足要求。
进一步地,在将多个原始资源文件合并为至少两个文件时,可以将相同格式的文件合并为同一个资源文件,例如,可以将1.png、7.png合并为一个文件,将4.xml、8.xml合并为一个资源文件。
以上介绍了在编译阶段生成合并文件的方法,然而合并的目的是为了在APP启动后加快页面显示的速度,下面对APP启动后,本申请实施例提供的方法300进行介绍。
当用户在电子设备上启动了某款APP或者用户在该APP启动后进行了页面切换操作,此时电子设备会根据用户的操作,向用户显示相应的页面。
例如,用户在电子设备上启动了华为游戏APP,此时,电子设备需要向用户显示的页面可以是华为游戏APP的首页,首页的界面内容101如图1中的(a)图所示;或者,用户在界面内容101上,进行了从首页切换至关注页面的操作,例如,用户在界面内容101上点击了关注选项,此时,电子设备需要向用户显示关注页面,关注页面的界面内容102如图1中的(b)图所示。
图7示出了本申请实施例提供的方法300的示意性流程图。方法300包括以下步骤。值得一提的是,本申请实施例涉及的加载文件的过程,可以是先将文件从非易失性存储器中读取出来,再将读取到的文件存储到随机存取存储器的过程。通过将合并文件从非易失性存储器存储到随机存取存储器,可以使得从合并文件中连续读取原始资源文件。
步骤310,根据资源索引文件,获取第一信息,资源索引文件包括多个资源文件的索引、文件名与路径信息,多个资源文件包括第一资源文件与第二资源文件,第一信息包括第一文件的路径信息与文件名。
步骤320,根据第一信息,加载第一文件,第一文件是由第一资源文件与第二资源文件合并后生成的,第一资源文件与第二资源文件属于第一页面。
步骤330,根据第二信息,从第一文件中获取第一资源文件与第二资源文件,第二信息用于从第一资源文件中提取第一资源文件与第二资源文件。
步骤340,根据第一资源文件与第二资源文件,电子设备显示第一页面。
以下以电子设备显示首页、或显示首页与关注页为例,对本申请实施例提供的加载资源的方法300分场景进行说明。
场景1,在编译阶段,将首页包括的两个原始资源文件合并为了一个文件。
例如,如图8所示,在显示首页时,电子设备解析首页的页面布局文件,确定首页包括的原始资源文件的索引为ID001、ID004,之后依次加载ID001、ID004对应的原始资源文件,以显示首页。
例如,假设电子设备最先加载的是ID001对应的原始资源文件,由于在编译阶段,将首页包括的ID001对应的原始资源文件1.png与ID004对应的原始资源文件4.xml合并为了一个文件,因此,在加载ID001对应的原始资源文件时,实际加载的是合并文件。
在加载ID001对应的原始资源文件时,电子设备根据资源索引文件,确定ID001对应的文件名以及路径信息,此处的文件名以及路径信息是合并文件的文件名以及路径信息, 根据文件名以及路径信息,电子设备加载合并文件。
在完成合并文件的加载后,电子设备需要从合并文件中读取ID001对应的原始资源文件,此时,可以根据确定的ID001对应的原始资源文件在合并文件中的偏移量以及ID001对应的原始资源文件的长度,从合并文件中读取ID001对应的原始资源文件,并根据ID001对应的原始资源文件显示首页。关于确定ID001对应的原始资源文件在合并文件中的偏移量以及ID001对应的原始资源文件的长度的方法请参考方法200中的相关描述,为了简洁,此处不再赘述。
在加载ID004对应的原始资源文件时,电子设备根据资源索引文件,确定ID004对应的文件名以及路径信息,这里根据ID004从资源索引文件中确定的文件名与路径信息与根据ID001从资源索引文件中确定的文件名与路径信息是一致的,电子设备在加载ID004对应的原始资源文件时,实际加载的是合并文件,但由于在加载ID001对应的原始资源文件时已经完成了合并文件的加载,因此,电子设备可以忽略本次加载,直接从已经加载的合并文件中读取ID004对应的原始资源文件,并根据ID004对应的原始资源文件显示首页。
值得一提的是,在完成合并文件的加载后,会延迟释放加载内容,换句话说,在完成合并文件的加载后,不会立即释放加载的内容,而是要等到合并文件中的原始资源文件全部被读取之后,才有可能释放加载的内容。
例如,可以在合并文件中对已经获取的原始资源文件进行标记,当合并文件中的所有原始资源均被标记之后,代表合并文件中的所有原始资源文件均被读取,此时可以释放合并文件。
方法300中的第一页面可以对应首页,第一资源文件可以对应ID001对应的原始资源文件,第二资源文件可以对应ID004对应的原始资源文件,第一文件可以对应ID001对应的原始资源文件与ID004对应的原始资源文件合并后生成的文件,第一信息可以对应合并文件的文件名以及路径信息,第一文件可以对应合并文件。场景2,在编译阶段,将首页包括的多个原始资源文件合并为了一个文件。
例如,如图9所示,在显示首页时,电子设备解析首页的页面布局文件,确定首页包括的原始资源文件的索引为ID001、ID002、ID004、ID006,之后依次加载ID001、ID002、ID004、ID006对应的原始资源文件,以显示首页。
例如,假设电子设备最先加载的是ID001对应的原始资源文件,由于在编译阶段,将首页包括的ID001对应的原始资源文件1.png、ID002对应的原始资源文件2.png、ID004对应的原始资源文件4.xml、ID006对应的原始资源文件6.json合并为了一个文件,因此,在加载ID001对应的原始资源文件时,实际加载的是合并文件。
在加载ID001对应的原始资源文件时,电子设备根据资源索引文件,确定ID001对应的文件名以及路径信息,此处的文件名以及路径信息是合并文件的文件名以及路径信息,根据文件名以及路径信息,电子设备加载合并文件。
在完成合并文件的加载后,电子设备需要从合并文件中读取ID001对应的原始资源文件,此时,可以根据确定的ID001对应的原始资源文件在合并文件中的偏移量以及ID001对应的原始资源文件的长度,从合并文件中读取ID001对应的原始资源文件,并根据ID001对应的原始资源文件显示首页。关于确定ID001对应的原始资源文件在合并文件中的偏移量以及ID001对应的原始资源文件的长度的方法请参考方法200中的相关描述,为了简洁, 此处不再赘述。
下面以ID002对应的原始资源文件的加载过程为例,对首页的其他原始资源文件的加载过程进行简要说明。
在加载ID002对应的原始资源文件时,电子设备根据资源索引文件,确定ID002对应的文件名以及路径信息,这里根据ID002从资源索引文件中确定的文件名与路径信息与根据ID001从资源索引文件中确定的文件名与路径信息是一致的,电子设备在加载ID002对应的原始资源文件时,实际加载的是合并文件,但由于在加载ID001对应的原始资源文件时已经完成了合并文件的加载,因此,电子设备可以忽略本次加载,直接从已经加载的合并文件中读取ID002对应的原始资源文件,并根据ID002对应的原始资源文件显示首页。
关于电子设备在合并文件读取ID002对应的原始资源文件的方法请参考前述在合并文件中读取ID001对应的原始资源文件的方法,关于加载ID004对应的原始资源文件的方法、加载ID006对应的原始资源文件的方法请参考场景1中的ID004对应的原始资源文件的加载过程,或,请参考场景2中的ID002对应的原始资源文件的加载过程,为了简洁,此处不再赘述。
值得一提的是,在完成合并文件的加载后,会延迟释放加载内容,换句话说,在完成合并文件的加载后,不会立即释放加载的内容,而是要等到合并文件中的原始资源文件全部被读取之后,才有可能释放加载的内容。
例如,可以在合并文件中对已经获取的原始资源文件进行标记,当合并文件中的所有原始资源均被标记之后,代表合并文件中的所有原始资源文件均被读取,此时可以释放合并文件。
场景3,在编译阶段,将具有关联关系的页面的原始资源文件合并为了一个文件,此处具有关联关系的页面例如可以是首页与关注页面。
例如,如图10所示,在显示首页时,电子设备解析首页的页面布局文件,确定首页包括的资源文件的索引为ID001、ID005,之后依次加载ID001、ID005对应的原始资源文件,以显示首页。
例如,假设电子设备最先加载的是ID001对应的原始资源文件,由于在编译阶段,将首页包括的原始资源文件1.png、原始资源文件5.xml与首页包括的原始资源文件2.png、原始资源文件6.jaon合并为了一个文件,因此,在加载ID001对应的原始资源文件时,实际加载的是合并文件。
在加载ID001对应的原始资源文件时,电子设备根据资源索引文件,确定ID001对应的文件名以及路径信息,此处的文件名以及路径信息是合并文件的文件名以及路径信息,根据文件名以及路径信息,电子设备加载合并文件。
在完成合并文件的加载后,电子设备需要从合并文件中读取ID001对应的原始资源文件,此时,可以根据确定的ID001对应的原始资源文件在在合并文件中的偏移量与ID001对应的原始资源文件的长度,从合并文件中读取ID001对应的原始资源文件,并根据ID001对应的原始资源文件显示首页。关于确定ID001对应的原始资源文件在合并文件中的偏移量以及ID001对应的原始资源文件的长度的方法请参考方法200中的相关描述,为了简洁,此处不再赘述。
关于首页包括的另一原始资源文件,即ID005对应的原始资源文件的加载过程请参考 场景1中的ID004对应的原始资源文件的加载过程,或,请参考场景2中的ID002对应的原始资源文件的加载过程,为了简洁,此处不再赘述。
首页显示完成之后,用户进行了从首页切换至关注页面的操作,此时电子设备需要显示关注页面,在显示关注页面时,电子设备解析关注页面的页面布局文件,确定关注页面包括的资源文件的索引为ID002、ID006,之后依次加载ID002、ID006对应的原始资源文件,以显示关注页面。
例如,假设电子设备最先加载的是ID002对应的原始资源文件,电子设备根据资源索引文件,确定ID002对应的文件名以及路径信息,这里根据ID002从资源索引文件中确定的文件名与路径信息与根据ID001从资源索引文件中确定的文件名与路径信息是一致的,电子设备在加载ID002对应的原始资源文件时,实际加载的是合并文件,但由于在加载ID001对应的原始资源文件时已经完成了合并文件的加载,因此,电子设备可以忽略本次加载,直接从已经完成加载的合并文件中读取ID002对应的原始资源文件,并根据ID002对应的原始资源文件显示关注页面。
关于电子设备在合并文件读取ID002对应的原始资源文件的方法请参考前述在合并文件读取ID001对应的原始资源文件的方法,关于ID006对应的原始资源文件的加载过程请参考场景1中的ID004对应的原始资源文件的加载过程,或,请参考场景2中的ID002对应的原始资源文件的加载过程,为了简洁,此处不再赘述。
值得一提的是,在完成合并文件的加载后,会延迟释放加载的内容,换句话说,在完成合并文件的加载后,不会立即释放加载的内容,而是要等到合并文件中的原始资源文件全部被读取之后,才有可能释放加载的内容。
例如,可以在合并文件中对已经获取的原始资源文件进行标记,当合并文件中的所有原始资源均被标记之后,代表合并文件中的所有原始资源文件均被读取,此时可以释放合并文件。
应理解,场景1至场景3中涉及的加载顺序仅作为示例性说明,并不对本申请实施例构成任何限定,在具体实现时,并不对原始资源文件的加载顺序进行限定。
图11示出了本申请实施例提供的另一种方法400的示意性流程图。方法400包括以下步骤。
步骤410,获取第一页面的页面布局文件。
步骤420根据第一页面的页面布局文件,确定第一页面包括第一资源文件与第二资源文件。
步骤430,对第一资源文件与第二资源文件进行合并,生成第一文件。
步骤440,根据资源索引文件,获取第一信息,资源索引文件包括多个资源文件的索引、文件名与路径信息,多个资源文件包括第一资源文件与第二资源文件,第一信息包括第一文件的路径信息与文件名。
步骤450,根据第一信息,加载第一文件。
步骤460,根据第二信息,从第一文件中获取第一资源文件与第二资源文件,第二信息用于从述第一资源文件中提取第一资源文件与第二资源文件。
步骤470,根据第一资源文件与第二资源文件,电子设备显示第一页面。
关于步骤410至430的具体实现请参考方法200中的相关描述,关于步骤440至470 的具体实现请参考方法300中的相关描述,为了简洁,此处不再赘述。
此外,本申请实施例还提供了一种文件,该文件包括资源索引文件与第一文件。
关于上述文件中的资源索引文件与第一文件的更具体的描述,请参考前述相关描述,为了简洁,此处不再赘述。可以理解的是,电子设备为了实现上述功能,其包含了执行各个功能相应的硬件和/或软件模块。结合本文中所公开的实施例描述的各示例的算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。本领域技术人员可以结合实施例对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本实施例可以根据上述方法示例对电子设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,例如处理模块、显示模块等,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块可以采用硬件的形式实现。需要说明的是,本实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
需要说明的是,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
本实施例提供的电子设备,用于执行上述生成文件的方法,因此可以达到与上述实现方法相同的效果。
在采用集成的单元的情况下,电子设备还可以包括处理模块、存储模块和通信模块。其中,处理模块可以用于对电子设备的动作进行控制管理。存储模块可以用于支持电子设备执行存储程序代码和数据等。通信模块,可以用于支持电子设备与其他设备的通信。
其中,处理模块可以是处理器或控制器。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理(digital signal processing,DSP)和微处理器的组合等等。存储模块可以是存储器。通信模块具体可以为射频电路、蓝牙芯片、Wi-Fi芯片等与其他电子设备交互的设备。
在一个实施例中,当处理模块为处理器,存储模块为存储器时,本实施例所涉及的电子设备可以为具有图2所示结构的设备。
本实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机指令,当该计算机指令在电子设备上运行时,使得电子设备执行上述相关方法步骤实现上述实施例中的生成文件的方法。
本实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述实施例中的生成文件的方法。
另外,本申请的实施例还提供一种装置,这个装置具体可以是芯片,组件或模块,该装置可包括相连的处理器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,处理器可执行存储器存储的计算机执行指令,以使芯片执行上述各方法实施例中的生成文件的方法。
其中,本实施例提供的电子设备、计算机存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方 法中的有益效果,此处不再赘述。
通过以上实施方式的描述,所属领域的技术人员可以了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (30)

  1. 一种方法,应用于电子设备,其特征在于,所述方法包括:
    根据资源索引文件,获取第一信息,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括第一资源文件与第二资源文件,所述第一信息包括第一文件的路径信息与文件名;
    根据所述第一信息,加载第一文件,所述第一文件是由所述第一资源文件与所述第二资源文件合并后生成的,所述第一资源文件与所述第二资源文件属于第一页面;
    根据第二信息,从所述第一文件中获取所述第一资源文件与所述第二资源文件,所述第二信息用于从所述第一资源文件中提取所述第一资源文件与所述第二资源文件;
    根据所述第一资源文件与所述第二资源文件,所述电子设备显示所述第一页面。
  2. 根据权利要求1所述的方法,其特征在于,所述第二信息包括所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量。
  3. 根据权利要求1或2所述的方法,其特征在于,所述第二信息包括所述第一资源文件的长度与所述第二资源文件的长度。
  4. 根据权利要求1至3中任一项所述的方法,其特征在于,所述第二信息保存在所述第一文件或所述资源索引文件中。
  5. 根据权利要求1至4中任一项所述的方法,其特征在于,所述第一资源文件与所述第二资源文件的类型相同。
  6. 根据权利要求1至5中任一项所述的方法,其特征在于,所述第一文件的长度小于或等于预设阈值。
  7. 一种生成文件的方法,其特征在于,所述方法包括:
    获取第一页面的页面布局文件;
    根据所述第一页面的页面布局文件,确定所述第一页面包括第一资源文件与第二资源文件;
    对所述第一资源文件与所述第二资源文件进行合并,生成第一文件。
  8. 根据权利要求7所述的方法,其特征在于,所述根据所述第一页面的页面布局文件,确定所述第一页面包括第一资源文件与第二资源文件,包括:
    根据所述第一页面的页面布局文件中包括的所述第一资源文件的标识与所述第二资源文件的标识,确定所述第一资源文件与所述第二资源文件属于所述第一页面。
  9. 根据权利要求7或8所述的方法,其特征在于,所述第一文件中存储有所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量,和/或,所述第一文件中存储有所述第一资源文件的长度与所述第二资源文件的长度。
  10. 根据权利要求7至9中任一项所述的方法,其特征在于,所述方法还包括:
    生成资源索引文件,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括所述第一资源文件与所述第二资源文件。
  11. 根据权利要求10所述的方法,其特征在于,所述资源索引文件中存储有所述第 一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量,和/或,所述第一文件中存储有所述第一资源文件的长度与所述第二资源文件的长度。
  12. 根据权利要求7至11中任一项所述的方法,其特征在于,所述第一资源文件与所述第二资源文件是根据所述第一页面的至少一个页面布局文件确定的。
  13. 根据权利要求7至12中任一项所述的方法,其特征在于,所述第一资源文件与所述第二资源文件的类型相同。
  14. 根据权利要求7至13中任一项所述的方法,其特征在于,所述第一文件的长度小于或等于预设阈值。
  15. 一种方法,应用于包括显示屏的电子设备,其特征在于,所述方法包括:
    获取第一页面的页面布局文件;
    根据所述第一页面的布局文件,确定所述第一页面包括第一资源文件与第二资源文件;
    对所述第一资源文件与所述第二资源文件进行合并,生成第一文件;
    根据资源索引文件,获取第一信息,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括所述第一资源文件与所述第二资源文件,所述第一信息包括所述第一文件的路径信息与文件名;
    根据所述第一信息,加载所述第一文件;
    根据第二信息,从所述第一文件中获取所述第一资源文件与所述第二资源文件,所述第二信息用于从所述第一资源文件中提取所述第一资源文件与所述第二资源文件;
    根据所述第一资源文件与所述第二资源文件,所述电子设备显示所述第一页面。
  16. 一种文件,其特征在于,所述文件包括根据权利要求7至14中任一项所述方法生成的第一文件,和/或,包括根据权利要求10至14中任一项所述方法生成的资源索引文件。
  17. 一种电子设备,包括显示屏,存储器,一个或多个处理器,以及一个或多个程序;其中所述一个或多个程序被存储在所述存储器中;其特征在于,所述一个或多个处理器在执行所述一个或多个程序时,使得所述电子设备执行如下步骤:
    根据资源索引文件,获取第一信息,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括第一资源文件与第二资源文件,所述第一信息包括第一文件的路径信息与文件名;
    根据所述第一信息,加载第一文件,所述第一文件是由所述第一资源文件与所述第二资源文件合并后生成的,所述第一资源文件与所述第二资源文件属于第一页面;
    根据第二信息,从所述第一文件中获取所述第一资源文件与所述第二资源文件,所述第二信息用于从所述第一资源文件中提取所述第一资源文件与所述第二资源文件;
    根据所述第一资源文件与所述第二资源文件,所述电子设备显示所述第一页面。
  18. 根据权利要求17所述的电子设备,其特征在于,所述第二信息包括所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量。
  19. 根据权利要求17或18所述的电子设备,其特征在于,所述第二信息包括所述第 一资源文件的长度与所述第二资源文件的长度。
  20. 根据权利要求17至19中任一项所述的电子设备,其特征在于,所述第二信息保存在所述第一文件或所述资源索引文件中。
  21. 根据权利要求17至20中任一项所述的电子设备,其特征在于,所述第一资源文件与所述第二资源文件的类型相同。
  22. 根据权利要求17至21中任一项所述的电子设备,其特征在于,所述第一文件的长度小于或等于预设阈值。
  23. 一种电子设备,包括存储器,一个或多个处理器,以及一个或多个程序;其中所述一个或多个程序被存储在所述存储器中;其特征在于,所述一个或多个处理器在执行所述一个或多个程序时,使得所述电子设备执行如下步骤:
    获取第一页面的页面布局文件;根据所述第一页面的页面布局文件,确定所述第一页面包括第一资源文件与第二资源文件;
    对所述第一资源文件与所述第二资源文件进行合并,生成第一文件。
  24. 根据权利要求23所述的电子设备,其特征在于,所述一个或多个处理器在执行所述一个或多个程序时,使得所述电子设备执行如下步骤:
    根据所述第一页面的页面布局文件中包括的所述第一资源文件的标识与所述第二资源文件的标识,确定所述第一资源文件与所述第二资源文件属于所述第一页面。
  25. 根据权利要求23或24所述的电子设备,其特征在于,所述第一文件中存储有所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量,和/或,所述第一文件中存储有所述第一资源文件的长度与所述第二资源文件的长度。
  26. 根据权利要求23至25中任一项所述的电子设备,其特征在于,所述一个或多个处理器在执行所述一个或多个程序时,使得所述电子设备执行如下步骤:
    生成资源索引文件,所述资源索引文件包括多个资源文件的索引、文件名与路径信息,所述多个资源文件包括所述第一资源文件与所述第二资源文件。
  27. 根据权利要求26所述的电子设备,其特征在于,所述资源索引文件中存储有所述第一资源文件的起始位置相对于所述第一文件的起始位置的偏移量与所述第二资源文件的起始位置相对于所述第一文件的起始位置的偏移量,和/或,所述第一文件中存储有所述第一资源文件的长度与所述第二资源文件的长度。
  28. 根据权利要求23至27中任一项所述的电子设备,其特征在于,所述第一资源文件与所述第二资源文件是根据所述第一页面的至少一个页面布局文件确定的。
  29. 根据权利要求23至28中任一项所述的电子设备,其特征在于,所述第一资源文件与所述第二资源文件的类型相同。
  30. 根据权利要求23至29中任一项所述的电子设备,其特征在于,所述第一文件的长度小于或等于预设阈值。
PCT/CN2021/116745 2020-09-18 2021-09-06 一种生成文件的方法及电子设备 WO2022057663A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP21868488.4A EP4206955A4 (en) 2020-09-18 2021-09-06 FILE GENERATION METHOD AND ELECTRONIC DEVICE
US18/027,035 US20230376459A1 (en) 2020-09-18 2021-09-06 File Generation Method and Electronic Device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010991909.3 2020-09-18
CN202010991909.3A CN114201703A (zh) 2020-09-18 2020-09-18 一种的生成文件的方法及电子设备

Publications (1)

Publication Number Publication Date
WO2022057663A1 true WO2022057663A1 (zh) 2022-03-24

Family

ID=80645297

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/116745 WO2022057663A1 (zh) 2020-09-18 2021-09-06 一种生成文件的方法及电子设备

Country Status (4)

Country Link
US (1) US20230376459A1 (zh)
EP (1) EP4206955A4 (zh)
CN (1) CN114201703A (zh)
WO (1) WO2022057663A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115982491A (zh) * 2023-03-20 2023-04-18 建信金融科技有限责任公司 页面更新方法及装置、电子设备和计算机可读存储介质

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073633A (zh) * 2009-11-23 2011-05-25 腾讯科技(深圳)有限公司 资源文件的存储访问方法及装置
CN102184231A (zh) * 2011-05-12 2011-09-14 广州市动景计算机科技有限公司 获取页面资源的方法及装置
WO2012167742A1 (zh) * 2011-07-27 2012-12-13 华为技术有限公司 资源文件的访问方法及装置
CN103020155A (zh) * 2012-11-23 2013-04-03 中国电信股份有限公司云计算分公司 一种Web前端资源请求处理方法及装置
CN103327033A (zh) * 2013-07-16 2013-09-25 星云融创(北京)信息技术有限公司 一种提高网络资源访问速度的方法及装置
CN109408750A (zh) * 2018-09-26 2019-03-01 中国平安财产保险股份有限公司 页面显示方法、装置、计算机设备和存储介质
CN111443942A (zh) * 2020-04-22 2020-07-24 广州虎牙科技有限公司 资源文件的打包方法、装置、存储介质和计算机设备

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6886132B1 (en) * 2000-06-06 2005-04-26 Microsoft Corporation Method and system for packing and unpacking web pages
US20020152245A1 (en) * 2001-04-05 2002-10-17 Mccaskey Jeffrey Web publication of newspaper content
US8417673B2 (en) * 2003-10-07 2013-04-09 International Business Machines Corporation Method, system, and program for retaining versions of files
US7516442B2 (en) * 2003-10-23 2009-04-07 Microsoft Corporation Resource manifest
US7676501B2 (en) * 2008-03-22 2010-03-09 Wilson Kelce S Document integrity verification
US11010409B1 (en) * 2016-03-29 2021-05-18 EMC IP Holding Company LLC Multi-streaming with synthetic replication
CN106020725B (zh) * 2016-05-20 2019-07-12 努比亚技术有限公司 应用文件处理装置及方法
CN109471643A (zh) * 2018-11-19 2019-03-15 苏州好玩友网络科技有限公司 一种手机游戏安装包配置方法及应用其的游戏安装运行方法

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073633A (zh) * 2009-11-23 2011-05-25 腾讯科技(深圳)有限公司 资源文件的存储访问方法及装置
CN102184231A (zh) * 2011-05-12 2011-09-14 广州市动景计算机科技有限公司 获取页面资源的方法及装置
WO2012167742A1 (zh) * 2011-07-27 2012-12-13 华为技术有限公司 资源文件的访问方法及装置
CN103020155A (zh) * 2012-11-23 2013-04-03 中国电信股份有限公司云计算分公司 一种Web前端资源请求处理方法及装置
CN103327033A (zh) * 2013-07-16 2013-09-25 星云融创(北京)信息技术有限公司 一种提高网络资源访问速度的方法及装置
CN109408750A (zh) * 2018-09-26 2019-03-01 中国平安财产保险股份有限公司 页面显示方法、装置、计算机设备和存储介质
CN111443942A (zh) * 2020-04-22 2020-07-24 广州虎牙科技有限公司 资源文件的打包方法、装置、存储介质和计算机设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4206955A4

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115982491A (zh) * 2023-03-20 2023-04-18 建信金融科技有限责任公司 页面更新方法及装置、电子设备和计算机可读存储介质

Also Published As

Publication number Publication date
EP4206955A4 (en) 2024-03-06
CN114201703A (zh) 2022-03-18
EP4206955A1 (en) 2023-07-05
US20230376459A1 (en) 2023-11-23

Similar Documents

Publication Publication Date Title
WO2021036735A1 (zh) 显示用户界面的方法及电子设备
CN114443277A (zh) 内存管理方法、装置、电子设备以及计算机可读存储介质
CN113553130B (zh) 应用执行绘制操作的方法及电子设备
WO2021159746A1 (zh) 文件共享方法、系统及相关设备
WO2021051982A1 (zh) 调用硬件接口的方法及电子设备
WO2021052311A1 (zh) 一种根据后壳颜色显示用户界面的方法和电子设备
CN114816167B (zh) 应用图标的显示方法、电子设备及可读存储介质
WO2022057663A1 (zh) 一种生成文件的方法及电子设备
WO2022052897A1 (zh) 调整内存配置参数的方法和装置
CN111381996A (zh) 内存异常处理方法及装置
WO2022252804A1 (zh) 显示视图控件的方法及装置
WO2022111664A1 (zh) 打补丁的方法、相关设备及系统
WO2021238376A1 (zh) 功能包的加载方法、装置、服务器和电子设备
CN115543276A (zh) 一种用于实现软件开发的方法、系统以及电子设备
CN114398108A (zh) 电子设备及其驱动加载方法、介质
WO2023165414A1 (zh) 一种接入电子设备的方法、系统以及装置
WO2022262291A1 (zh) 应用的图像数据调用方法、系统、电子设备及存储介质
WO2024067551A1 (zh) 界面显示方法及电子设备
EP4322144A1 (en) Display screen brightness adjustment method, electronic device and storage medium
WO2023001208A1 (zh) 多文件同步方法及电子设备
WO2023001033A1 (zh) 镜像启动的方法、生成镜像的方法和电子设备
CN115550631B (zh) 图像传感器的评估方法、电子设备及存储介质
CN116744106B (zh) 相机应用的控制方法和终端设备
CN115529379B (zh) 防止蓝牙音频Track音轨抖动的方法、电子设备及存储介质
WO2023246783A1 (zh) 调整设备功耗的方法及电子设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21868488

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021868488

Country of ref document: EP

Effective date: 20230331

NENP Non-entry into the national phase

Ref country code: DE