Export Method, Device, Electronic Device and Storage Medium for Private Directory Files
By creating a virtualized running environment and export logic on the client, the problem that ordinary machines cannot export application private directory files is solved, and a method of efficiently exporting private directory files on ordinary machines is realized.
Patent Information
- Application Number
- CN202110799220.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-15
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2041-07-15
AI Technical Summary
In the prior art, ordinary machines cannot export private directory files of installed and running applications, and machines with high permissions in the operating system are required to achieve export.
By creating a virtualized running environment on the client, running the target application, and storing its private directory files to the internal private directory, using preset functions to export the target private directory files from the internal private directory based on the export logic.
It realizes the export of private directory files of the target application on ordinary machines, lowers the threshold for obtaining private directory files, improves the export speed and versatility, and ensures the efficiency of development and testing.
Smart Images

Figure CN113407490B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet communication technologies, and in particular, to a method, apparatus, electronic device, and storage medium for exporting private directory files. Background Art
[0002] With the development of Internet communication technologies, various Internet products emerge in an endless stream. For application-based Internet products, obtaining files in their private directories is a common requirement in the development and testing phases, and even ordinary users have such a requirement to obtain cached picture files, etc.
[0003] In related technologies, obtaining private directory files of an application is usually achieved through the following method: by means of a machine with high operating system privileges, which thus has read and write permissions for the private directory, and can thereby export the private directory files of the installed and running application. However, with the increasingly standardized market requirements, it is not easy to obtain a machine with high operating system privileges, and ordinary machines (machines without high operating system privileges) cannot export the private directory files of the installed and running application. Therefore, a solution for an application to export private directory files on an ordinary machine is needed. Summary of the Invention
[0004] To solve the problems in the prior art that an ordinary machine cannot export the private directory files of an installed and running application when the application exports its private directory files, etc., the present application provides a method, apparatus, electronic device, and storage medium for exporting private directory files:
[0005] According to a first aspect of the present application, there is provided a method for exporting private directory files, which is applied to a client, and the method includes:
[0006] Create a virtualized running environment;
[0007] Run a target application in the virtualized running environment; wherein, during the running process, store the target private directory files corresponding to the target application under the internal private directory corresponding to the client;
[0008] Export the target private directory files from the files under the internal private directory based on a preset function; wherein, the preset function indicates the export logic for the files under the internal private directory.
[0009] According to a second aspect of the present application, there is provided an apparatus for exporting private directory files, which is configured in a client, and the apparatus includes:
[0010] A creation module: for creating a virtualized running environment;
[0011] Running module: used to run a target application in the virtualized running environment; wherein, during the running process, the target private directory file corresponding to the target application is stored under the internal private directory corresponding to the client;
[0012] Export module: used to export the target private directory file from the files under the internal private directory based on a preset function; wherein, the preset function indicates the export logic for the files under the internal private directory.
[0013] According to the third aspect of the present application, there is provided an electronic device, which includes a processor and a memory. At least one instruction or at least one program segment is stored in the memory, and the at least one instruction or the at least one program segment is loaded and executed by the processor to implement the method for exporting a private directory file as described in the first aspect.
[0014] According to the fourth aspect of the present application, there is provided a computer-readable storage medium, in which at least one instruction or at least one program segment is stored, and the at least one instruction or the at least one program segment is loaded and executed by a processor to implement the method for exporting a private directory file as described in the first aspect.
[0015] According to the fifth aspect of the present application, there is provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method for exporting a private directory file as described in the first aspect.
[0016] The method, device, electronic device and storage medium for exporting a private directory file provided by the present application have the following technical effects:
[0017] The present application creates a virtualized running environment through the client, then runs the target application in the virtualized running environment, and then exports the target private directory file corresponding to the target application from the files under the internal private directory corresponding to the client based on a preset function. Among them, during the running process of the target application, the client stores the target private directory file under the internal private directory, and the preset function indicates the export logic for the files under the internal private directory. The present application uses the virtualized running environment provided by the client to run the target application, so that the private directory file of the target application is stored under the internal private directory. Through the export logic set for the files under the internal private directory, the export of the private directory file of the target application is realized. In this way, the private directory file of the target application can be exported on an ordinary machine, and the speed and generality of the export of the private directory file are improved by means of the client, thus ensuring the efficiency of development and testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] To more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0019] Figure 1 is a schematic diagram of an application environment provided by an embodiment of the present application;
[0020] Figure 2 is a schematic flowchart of a method for exporting a private directory file provided by an embodiment of the present application;
[0021] Figure 3 is a schematic flowchart of a process for running a target application using a process provided by an embodiment of the present application;
[0022] Figure 4 is a schematic flowchart of a process for hijacking a storage path acquisition interface provided by an embodiment of the present application;
[0023] Figure 5 is also a schematic flowchart of a method for exporting a private directory file provided by an embodiment of the present application;
[0024] Figure 6 is also a schematic flowchart of a method for exporting a private directory file provided by an embodiment of the present application;
[0025] Figure 7 is a schematic diagram of a virtualized operating environment framework provided by an embodiment of the present application;
[0026] Figure 8 is also a schematic flowchart of a method for exporting a private directory file provided by an embodiment of the present application;
[0027] Figure 9 is a block diagram of the composition of a device for exporting a private directory file provided by an embodiment of the present application;
[0028] Figure 10 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0029] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0030] It should be noted that the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned accompanying drawings are intended to cover non-exclusive inclusion. For example, a process, method, system, product or server including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0031] Before further elaborating on the embodiments of the present application, the nouns and terms involved in the embodiments of the present application are described. The nouns and terms involved in the embodiments of the present application are applicable to the following explanations.
[0032] Root permission: It is a type of system permission, also known as root permission. Root is the super administrator account in the Linux system (an operating system), and it has the highest permission for the entire system. It can conveniently perform any deletion, modification, addition, etc. operations on the system.
[0033] / data / data / directory: Also known as the private directory or data directory. In the Android system, it is used to store files that the app (application) expects to write to the local storage medium during operation. Restricted by permissions, ordinary Android system users cannot access this directory.
[0034] Hook: It refers to the technique of hijacking using reflection, dynamic proxy, or virtual machine methods, etc., to modify the Java (a programming language) logic within the current process, thereby changing the program execution result and ultimately achieving the coding purpose.
[0035] Context object: It refers to the context object during the operation of an Android application. It undertakes many core tasks during the operation of the application. Its base class is "android.content.Context", and the core implementation class is "android.app.ContextImpl".
[0036] Virtualization running technology: It refers to the technology that enables the Android platform to run apk (Android application package) files based on the idea of simulating the Android system. This type of technology can run apk files without installing them on the Android system. It can be used for dual-opening operations of some functional apps and is also used for debugging and modifying apk files.
[0037] DroidPlugin: An open-source framework for the Android platform that can be used to build a virtualization running environment for simulating the Android system to run apk files in the virtualization running environment.
[0038] Java reflection technology: It refers to the ability of a computer program to access, detect, and modify its own state or behavior during runtime. Java, as a programming language, provides a set of reflection interfaces itself, and developers can easily implement reflection operations on the code logic within the process using these interfaces (such as APIs (application programming interfaces)).
[0039] Please refer to Figure 1 , Figure 1 FIG. X is a schematic diagram of an application environment provided by an embodiment of the present application. The application environment may include a terminal 10 and a server 20. The terminal 10 and the server 20 may be directly or indirectly connected through a wired or wireless communication method. A client is running on the terminal 10, and the target application runs in the virtualization running environment provided by the client. The private directory files of the target application are stored in the corresponding internal private directory of the client. Through the export logic set for the files in the internal private directory, the export of the private directory files of the target application is achieved. It should be noted that Figure 1 is merely an example.
[0040] The terminal 10 may be a physical device such as a smart phone, a desktop computer, a tablet computer, a laptop computer, an augmented reality (AR) / virtual reality (VR) device, a digital assistant, a smart speaker, a smart wearable device, etc. The operating system corresponding to the terminal may be an Android system, an IOS system (a mobile operating system developed by Apple Inc.), a Linux system (an operating system), a Microsoft Windows system (Microsoft Windows operating system), etc. The client may be software running on the terminal 10, such as a computer program.
[0041] The server 20 can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The server can include a network communication unit, a processor, a memory, and so on. The server can provide background services for the corresponding client.
[0042] In practical applications, the terminal can be a mobile terminal, such as a mobile phone. The operating system corresponding to the terminal can be the Android system. The client can be an application that can provide a virtualized running environment. The target application can be a test application that needs to obtain the files in its private directory during the development and testing process. The test application can be a game application, and the game types provided by the game application can be ACT (Action), adventure, RPG (Role-playing game), narrative, strategy, FPS (First-person shooting), fighting, puzzle-solving, arcade, science fiction, open world, survival, etc.
[0043] Taking the test application as a character customization game application as an example. If it is necessary to test its function of "saving the customized image of the game virtual character confirmed to be saved into the private directory", then on the basis of writing the relevant code for the character customization game application to implement the function of "saving the customized image of the game virtual character confirmed to be saved into the private directory", run the above client on an ordinary machine, and run the character customization game application in the virtualized running environment provided by the client. All relevant (even all) player operations (such as the operation of "confirming to save the customized image of the game virtual character") of the character customization game application running in the virtualized running environment are carried out in the private directory of the client. Therefore, some files in the private directory of the client can be exported to realize the export of the private directory files of the character customization game application. By checking whether the exported private directory files include the "customized image of the game virtual character confirmed to be saved", it can be determined whether the character customization game application has the function of "saving the customized image of the game virtual character confirmed to be saved into the private directory".
[0044] The following introduces a specific embodiment of a method for exporting private directory files of the present application. Figure 2It is a schematic flowchart of a method for exporting private directory files provided by an embodiment of the present application. The present application provides method operation steps as described in the embodiment or flowchart, but based on routine or non-creative labor, it may include more or fewer operation steps. The step order listed in the embodiment is only one of the execution orders of numerous steps and does not represent the only execution order. When the actual system or product is executed, it can be executed in the order of the method shown in the embodiment or the accompanying drawings or executed in parallel (for example, in an environment of parallel processors or multi-threaded processing). Specifically, as Figure 2 shown, the method may include:
[0045] S201: Create a virtualized operating environment;
[0046] In the embodiment of the present application, the client creates a virtualized operating environment. The client can be an application. The client can create a virtualized operating environment based on virtualization running technology and combined with the technology of Java layer hook. It should be noted that the client runs on a terminal, and the terminal can be an ordinary machine that does not obtain high permissions of the operating system. For example, the terminal can be an Android mobile phone that does not obtain root permission. The installation package file of the client can be installed on the terminal to realize the operation of the client.
[0047] In an exemplary embodiment, the creating of the virtualized operating environment may include: creating a process indicating simulated operation based on a preset framework.
[0048] The preset framework is used to build a virtualized operating environment that simulates an operating system. The preset framework can be an open-source and mature framework or a self-developed highly adaptable framework. The client creates a process indicating simulated operation based on the preset framework, thereby realizing the creation of the virtualized operating environment. The process indicating simulated operation can be used to run the application to be tested, and the operating environment of the application to be tested is not affected by and is isolated from the operating environment provided by the terminal. With the help of the preset framework, the convenience and efficiency of the client to complete the work of creating the virtualized operating environment can be improved.
[0049] Furthermore, the client can also create a first type of process based on the preset framework; wherein, the first type of process is used to display the interface control for exporting the private directory file; create a second type of process based on the preset framework; wherein, the second type of process is used to record and transfer the process information for exporting the private directory file.
[0050] The process of simulating the aforementioned instructions can be regarded as the third type of process. A virtualized operating environment is created based on the first type of process, the second type of process, and the third type of process. The virtualized operating environment created by the three types of processes focuses on the scenario of exporting private directory files. Displaying relevant interface controls can improve the operation convenience of developers and testers. Recording and transmitting relevant process information can better maintain the relevant information for the export of specific private directory files, thus ensuring the stability of the export of private directory files.
[0051] See Figure 7 , the first type of process can be the main process (Host) of the client, which is responsible for the display of the user interface (UI) of the client. The user interface of the client it is responsible for can include the overall user interface framework of the client, which can include displaying relevant interactive operation controls and responding to trigger operations for the relevant interactive operation controls. The relevant interactive operation controls can include buttons for indicating the installation and uninstallation of the installation package file of the application to be tested. The relevant interactive operation controls can also include a button for indicating the export of the private directory file of a certain test application. The private directory file of a certain test application is the file output after the test application runs in the virtualized operating environment provided by the client and needs to be exported from the corresponding internal private directory of the client. This button can be associated with a preset directory for storing the exported file, and the preset directory can indicate an external storage directory, that is, a directory on a common storage medium outside the terminal where the client runs, such as the public directory (such as the cache directory) of an external sd card (Secure Digital Card). The button for indicating the installation and uninstallation of the installation package file of the application to be tested and the button for indicating the export of the private directory file of a certain test application can be used as interface controls for the export of private directory files.
[0052] The second type of process can serve as a unified management process, which can be understood as the daemon process of the entire client. It is responsible for the installation management of installation package files, the startup and stack management of system components, the management of the third type of process, etc. The second type of process is used to record the process information exported for private directory files. It can be responsible for recording the status information of the (to-be) tested application by the second type of process. For example, it records the storage location of the installation package file of the to-be-tested application, the name of the installation package file, and whether the installation package file has been installed; it records the page running order and operation (such as operations to open and exit the tested application) information corresponding to the tested application running in the virtual running environment. The second type of process is used to transfer the process information exported for private directory files. For example, it transfers the installation instruction, uninstallation instruction, and export instruction obtained in response to the button trigger as described above. The second type of process can provide a cross-process call interface. It can maintain some interface capabilities required by the main process and the third type of process, and provide a unified capability output interface for convenient process calls, which is equivalent to establishing communication between the first type of process and the third type of process. In practical applications, the installation package file management responsible for by the second type of process can be for apk files. The system component startup and stack management responsible for by the second type of process can be for Activity (an Android system component), and the Activity stack management can include the Activity pages of the tested application running in simulation.
[0053] S202: Run the target application in the virtualized running environment; wherein, during the running process, store the target private directory file corresponding to the target application under the internal private directory corresponding to the client;
[0054] In the embodiment of the present application, the client runs the target application in the virtualized running environment. The target application can be a tested application that needs to obtain the files in its private directory during the development and testing process. The target application runs in the virtualized running environment provided by the client. During the running process, the client stores the target private directory file corresponding to the target application under the internal private directory corresponding to the client. That is to say, with the help of the virtualized running environment provided by the client, the interface redirection operation for the private directory files of the tested application is completed, and the directory allocation for the tested application is realized. In this way, the file writing action for the tested application is redirected to the internal private directory. Among them, the target private directory file is the file in the private directory of the target application, and the internal private directory is the private directory of the client. The file written to the private directory of the target application can be determined based on the content pre-agreed in the configuration information of the tested application. Combining with the process (hereinafter referred to as "the third type of process") indicating the simulated running created in the foregoing steps, the client can use this process to run the target application.
[0055] In an exemplary embodiment, running the target application using the process includes performing the following steps using the process: First, determine the target installation package file corresponding to the target application from the files in the specified directory; then, decompress the target installation package file to obtain library files; furthermore, construct a class loader object based on the path information of the target installation package file and the path information of the library files; finally, use the class loader object to load the target installation package file to run the target application.
[0056] The specified directory indicates the storage path of the installation package file of the application to be simulated and run, and this path can be located on a local storage medium. The files in the specified directory can be copied and stored by the aforementioned second type of process. The third type of process determines the target installation package file corresponding to the target application from the files in the specified directory. The third type of process can determine the identification information of the target application based on the requirement information in the development and testing phase, and then determine the matching target installation package file from the files in the specified directory according to the identification information. This identification information can be the name of the target installation package file. In practical applications, the target installation package file can be an apk file, and the apk file contains the code for reflecting the running logic of the target application. The apk file can include dex files (dalvik executable format files, a type of executable file) and so files (shared object files, a type of library file). The apk file can be installed and run on an Android device.
[0057] The third type of process decompresses the target installation package file to obtain library files, such as so files. The third type of process constructs a class loader (ClassLoader) object based on the path information of the target installation package file and the path information of the library files. The path information of the target installation package file indicates the storage location of the target installation package file, and the path information of the library files indicates the storage location of the library files. The third type of process uses the class loader object to load the target installation package file to run the target application.
[0058] The client uses its own process to run the target installation package file, so that the running of the target application implemented in the virtualized running environment is basically the same as the running of the target application achieved by installing the target installation package file on the terminal, and the execution of their respective running logics is also basically the same. For example, if the virtualized running environment provided by the client is created by simulating the Android system, then the effect of running the apk file of the test application in the virtualized running environment is basically the same as the effect of installing and running the apk file on an Android device.
[0059] In an exemplary embodiment, as Figure 3 shown, running the target application using the process includes:
[0060] S301: In response to request information for the target application, use the process to determine the response logic of the target application;
[0061] S302: When the response logic includes a call function for an interface of a specified operating system, use the process to hijack the call function and modify the call function based on the relationship between itself and the specified operating system;
[0062] S303: Use the process to execute the modified call function.
[0063] The client uses its own process to implement the operation of the target application, and the operation logic of the target application needs to be executed normally. Considering that the operation logic of the target application is often designed for the operating environment provided by the terminal,
[0064] when the target application runs in the operating environment provided by the client, an exception may occur when executing the original operation logic. Therefore, the client will make an adaptive adjustment to the original operation logic to ensure the realization of the original operation effect.
[0065] In response to request information for the target application, the client uses a third type of process to determine the response logic of the target application. The request information can be sent by a target object (such as a user, simulator), for example, request information 1 is "jump to page 5". The client uses a third type of process to determine the response logic of the target application for the request information, such as the response logic for request information 1. If the response logic includes a call function for an interface of a specified operating system, then the client uses a third type of process to hijack (hook) the call function and modify the call function based on the relationship between itself and the specified operating system, so as to execute the modified call function. Of course, if the response logic does not include a call function for an interface of a specified operating system, then the call function can be directly executed.
[0066] The specified operating system is the operating system adapted by the target application, that is, the target application is developed for the specified operating system. For example, if the target application is an Android application, then the specified operating system is the Android system. The execution of the call function for the interface of the specified operating system may be abnormal due to the aforementioned operating environment. When the client uses a third type of process to make an adaptive adjustment to the relevant call function, it needs to consider the relationship between itself and the specified operating system. For example, when the client runs on an Android device, it can adjust the call function to bypass the virtualized operating environment that emulates the Android system and be associated with the operating system of the Android device. Otherwise, the call to the native API of the Android system (also known as the Android framework API, corresponding to the interface of the specified operating system) may be blocked or reported as an error by the Android system, and these APIs cannot be correctly called, thus affecting the normal execution of the response logic.
[0067] Of course, the specified operating system may also be different from the operating system of the device running the client. For example, the client runs on an IOS device to create a virtualized operating environment that simulates the Android system to run the target application (corresponding to the Android system). At this time, the client can convert the interface of the specified operating system (Android system) into an interface corresponding to the IOS system, and adjust the relevant parameters of the calling function to associate it with the operating system of the IOS device by bypassing the virtualized operating environment that simulates the Android system. The client uses the third type of process to execute the modified calling function, so that the third type of process can fully present the running effect of the target application.
[0068] S203: Exporting the target private directory file from the files in the internal private directory based on a preset function; wherein the preset function indicates an export logic for the files in the internal private directory.
[0069] In an embodiment of the present application, the private directory file (target private directory file) of the target application running in the virtualized operating environment is allocated to the private directory (internal private directory) of the client. When exporting the target private directory file, it can be implemented with the help of a preset function. The preset function indicates the export logic for the files under the internal private directory, and the export logic can be pre-embedded with the help of the client's source code. The client has read and write permissions for its private directory, can obtain the client's source code, and use this permission to perform source code engineering to pre-embed the logic code for copying and copying the private directory. Based on the preset function, the client can export the files under its private directory.
[0070] In an exemplary embodiment, Figure 4 As shown, before exporting the target private directory file from the files in the internal private directory based on the preset function, the method further includes:
[0071] S401: Determine a storage path acquisition interface of the target application's execution context object;
[0072] S402: Modify the return value of the storage path acquisition interface to be a target private directory; wherein the target private directory is a designated subdirectory of the internal private directory, and the return value of the storage path acquisition interface indicates the storage path of the target private directory file.
[0073] During the running process, the client stores the target private directory file corresponding to the target application in the internal private directory corresponding to the client. Considering that the client may face more than one test application, and the private directory files of all test applications are stored in the internal private directory, it will be difficult to accurately export the target private directory file. Even if "the writing of the private directory file of the test application needs to first obtain the storage path acquisition interface through the corresponding running context object, and then obtain the directory information based on the storage path acquisition interface, so as to write the corresponding private directory file to the directory corresponding to the directory information", when the running context objects corresponding to the two tests are the same, it will be difficult to accurately export the target private directory file.
[0074] The client determines the storage path acquisition interface of the target application's running context object. The storage path acquisition interface can be at least one of the following: getDateDir(), getFilesDir() and getDir(). In combination with the records in the aforementioned S202, the target application is run using a third-class process. If there is a test application a running by a third-class process a, a test application b running by a third-class process b, and a test application c running by a third-class process c at the same time, the running context object a corresponding to the test application a, the running context object b corresponding to the test application b, and the running context object c corresponding to the test application c are different, and the return values of the storage path acquisition interface of different running context objects are also different. In actual applications, the private directory involved in the target application of the Android application, its related interface is in the "android.content.Context" class.
[0075] The client modifies the return value of the storage path acquisition interface to the target private directory. The target private directory is a designated subdirectory of the internal private directory, and the return value of the storage path acquisition interface indicates the storage path of the target private directory file. The designated subdirectory can be a newly created one specifically for writing private directory files of the target application, or it can be an existing subdirectory that is used based on the needs of the development and testing phase. Of course, the designated subdirectory can also use the directory corresponding to the above directory information. When the return value of the storage path acquisition interface is changed from the original directory information to the target private directory, the private directory files of the target application will be written to the target private directory. The modification of the return value can use the technical means of hook, which can be seen in Figure 8 The target private directory is determined as the storage path of the target private directory file in the internal private directory, which can effectively filter irrelevant storage paths of the internal private directory and improve the accuracy and efficiency of exporting the target private directory file.
[0076] Further, before modifying the return value of the storage path acquisition interface to the target private directory, the method further includes: determining a corresponding directory name based on the feature information of the target application; naming the target private directory with the directory name. Correspondingly, the exporting the target private directory file from the files under the internal private directory based on a preset function includes: determining the target private directory from the internal private directory based on the directory name; exporting the files under the target private directory based on the preset function; wherein, the files under the target private directory are the target private directory files.
[0077] The client determines a corresponding directory name based on the feature information of the target application. The feature information of the target application can be the business information of the target application (such as the instant messaging service), the product information of the target application, and the installation package file information of the target application. Correspondingly, the determined directory name can be the business name, the product name, and the name of the target installation package file. The client names the target private directory with the directory name, and the target private directory indicates the storage path of the target private directory file. On this basis, the target private directory can be accurately and efficiently located from the internal private directory through the directory name, so as to export the files under the target private directory based on a preset function to implement the export of the target private directory file.
[0078] See Figure 5 、 6 And 8 below will introduce the application of the private directory file export solution provided by this application with examples, where the client can be used in development tools.
[0079] 1) Build a test application whose core implementation is the function of "storing a test picture in the private directory", and the relevant code is as follows:
[0080]
[0081] 2) Run the test application on an ordinary machine, and get a prompt of no permission to view when viewing the private directory.
[0082] 3) Run the client on an ordinary machine, and run the test application in the virtualized running environment provided by the client. All relevant (even all) file operations (such as the operation of "storing a test picture in the private directory") of the test application running in the virtualized running environment are performed under the private directory of the client. Therefore, some files under the private directory of the client can be exported to implement the export operation of the private directory file of the test application. Among them, the export code for the private directory of the client is as follows:
[0083]
[0084]
[0085] The export operation can be completed by copying the private directory of the client to the external storage directory located on the SD card. After the test application runs in the virtualized operating environment, the file export operation can be triggered by the export button. Finally, the exported directory can be viewed on the external SD card, including the private directory of the test application that stores the "test picture". It should be noted that, in combination with the description in the foregoing step S202, the operation of "storing a test picture in the private directory" can be triggered when the test application is running using the third type of process (the process indicating simulated operation). Then, the third type of process can be exited and returned to the first type of process (the main process) to trigger the operation of exporting the file.
[0086] As can be seen from the technical solutions provided by the embodiments of the present application above, in the embodiments of the present application, a virtualized operating environment is created through the client, and then the target application is run in the virtualized operating environment. Then, based on a preset function, the target private directory file corresponding to the target application is exported from the files in the internal private directory corresponding to the client. Among them, during the running of the target application, the client stores the target private directory file in the internal private directory, and the preset function indicates the export logic for the files in the internal private directory. The present application uses the virtualized operating environment provided by the client to run the target application, so that the private directory file of the target application is stored in the internal private directory. Through the export logic set for the files in the internal private directory, the export of the private directory file of the target application is realized. In this way, the private directory file of the target application can be exported on an ordinary machine, which reduces the threshold for obtaining the private directory file of the target application and no longer requires relying on a machine with high operating system permissions. With the help of the client, the speed and generality of exporting the private directory file are improved, thus ensuring the efficiency of development and testing.
[0087] The embodiments of the present application also provide an apparatus for exporting a private directory file, as Figure 9 shown. The apparatus 900 for exporting the private directory file is configured in the client, and the apparatus includes:
[0088] A creation module 901: used to create a virtualized operating environment;
[0089] An operation module 902: used to run the target application in the virtualized operating environment; among them, during the running process, the target private directory file corresponding to the target application is stored in the internal private directory corresponding to the client;
[0090] An export module 903: used to export the target private directory file from the files in the internal private directory based on a preset function; among them, the preset function indicates the export logic for the files in the internal private directory.
[0091] It should be noted that the devices in the device embodiments and the method embodiments are based on the same inventive concept.
[0092] An embodiment of the present application provides an electronic device, which includes a processor and a memory. At least one instruction or at least one program segment is stored in the memory, and the at least one instruction or the at least one program segment is loaded and executed by the processor to implement the method for exporting a private directory file provided in the above method embodiment.
[0093] Furthermore, Figure 10 The figure shows a schematic hardware structure diagram of an electronic device for implementing the method for exporting a private directory file provided in the embodiment of the present application. The electronic device may participate in constituting or include the device for exporting a private directory file provided in the embodiment of the present application. As Figure 10 shown, the electronic device 100 may include one or more processors 1002 (shown as 1002a, 1002b,..., 1002n in the figure) (the processor 1002 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 1004 for storing data, and a transmission device 1006 for communication functions. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 10 the structure shown is only schematic and does not limit the structure of the above electronic device. For example, the electronic device 100 may further include more or fewer components than Figure 10 shown, or have a different configuration from Figure 10 shown.
[0094] It should be noted that the above one or more processors 1002 and / or other data processing circuits are generally referred to as "data processing circuits" in this document. The data processing circuit may be embodied in whole or in part as software, hardware, firmware, or any combination thereof. In addition, the data processing circuit may be a single independent processing module, or be incorporated in whole or in part into any one of the other elements in the electronic device 100 (or mobile device). As involved in the embodiment of the present application, the data processing circuit is used for processor control (such as the selection of a variable resistance terminal path connected to an interface).
[0095] The memory 1004 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method for exporting private directory files described in the embodiments of the present application. The processor 1002 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, to implement the above-mentioned method for exporting private directory files. The memory 1004 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 1004 may further include a memory remotely disposed relative to the processor 1002, and these remote memories can be connected to the electronic device 100 through a network. Examples of the above-mentioned network include but are not limited to the Internet, enterprise intranets, local area networks, mobile communication networks, and combinations thereof.
[0096] The transmission device 1006 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of the electronic device 100. In one instance, the transmission device 1006 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one embodiment, the transmission device 1006 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0097] The display can be, for example, a touch-screen liquid crystal display (LCD), and this liquid crystal display enables a user to interact with the user interface of the electronic device 100 (or mobile device).
[0098] Embodiments of the present application also provide a computer-readable storage medium. The storage medium can be disposed in an electronic device to store at least one instruction or at least one segment of a program related to implementing the method for exporting private directory files in the method embodiments. The at least one instruction or the at least one segment of the program is loaded and executed by the processor to implement the method for exporting private directory files provided in the above-mentioned method embodiments.
[0099] Optionally, in this embodiment, the above-mentioned storage medium can be located in at least one of multiple network servers of a computer network. Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks, or optical discs and other media that can store program codes.
[0100] It should be noted that the above order of the embodiments of the present application is only for description and does not represent the superiority or inferiority of the embodiments. Moreover, the specific embodiments of the present application have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require the particular order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0101] Each embodiment in the present application is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the device and the electronic device, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments.
[0102] Those of ordinary skill in the art can understand that all or part of the steps to implement the above embodiments can be completed by hardware, or can be completed by a program instructing the relevant hardware. The program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a magnetic disk, an optical disc, etc.
[0103] The above are only the preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for exporting a private directory file, characterized in that, the method is applied to a client, and the method includes: creating a virtualized running environment; running a target application in the virtualized running environment, and storing the target private directory file corresponding to the target application in the internal private directory corresponding to the client during the running process; exporting the target private directory file from the files in the internal private directory based on a preset function, where the preset function indicates the export logic for the files in the internal private directory; wherein, creating the virtualized running environment includes: creating a process indicating simulated running based on a preset framework; running the target application in the virtualized running environment includes: running the target application using the process; wherein, running the target application using the process includes: in response to request information for the target application, using the process to determine the response logic of the target application; when the response logic includes a call function for an interface of a specified operating system, using the process to hijack the call function and modifying the call function based on the relationship between itself and the specified operating system; using the process to execute the modified call function.
2. The method according to claim 1, characterized in that, before exporting the target private directory file from the files in the internal private directory based on the preset function, the method further includes: determining an interface for obtaining the storage path of the running context object of the target application; modifying the return value of the storage path obtaining interface to be the target private directory; wherein, the target private directory is a specified sub-directory of the internal private directory, and the return value of the storage path obtaining interface indicates the storage path of the target private directory file.
3. The method according to claim 2, characterized in that: before modifying the return value of the storage path obtaining interface to be the target private directory, the method further includes: determining a corresponding directory name based on the characteristic information of the target application; naming the target private directory with the directory name; exporting the target private directory file from the files in the internal private directory based on the preset function includes: determining the target private directory from the internal private directory based on the directory name; exporting the files under the target private directory based on the preset function; wherein, the files under the target private directory are the target private directory files.
4. The method according to claim 1, characterized in that, running the target application using the process includes using the process to execute the following steps: determining a target installation package file corresponding to the target application from the files in a specified directory; wherein, the specified directory indicates the storage path of the installation package file of the application to be simulated; performing decompression processing on the target installation package file to obtain library files; constructing a class loader object based on the path information of the target installation package file and the path information of the library files; loading the target installation package file using the class loader object to run the target application.
5. The method according to claim 1, wherein, the creating of the virtualized running environment further includes: creating a first type of process based on the preset framework; wherein, the first type of process is used to display an interface control for exporting private directory files; creating a second type of process based on the preset framework; wherein, the second type of process is used to record and transfer process information for exporting private directory files.
6. An apparatus for exporting private directory files, wherein, the apparatus is configured on a client, and the apparatus includes: a creating module: for creating a virtualized running environment; a running module: for running a target application in the virtualized running environment, and storing the target private directory file corresponding to the target application into the internal private directory corresponding to the client during the running; an exporting module: for exporting the target private directory file from the files in the internal private directory based on a preset function, and the preset function indicates the export logic for the files in the internal private directory; wherein, the creating of the virtualized running environment includes: creating a process indicating simulated running based on a preset framework; the running of the target application in the virtualized running environment includes: running the target application by using the process; wherein, the running of the target application by using the process includes: in response to request information for the target application, determining the response logic of the target application by using the process; when the response logic includes a call function for an interface of a specified operating system, hijacking the call function by using the process, and modifying the call function based on the relationship between itself and the specified operating system; and executing the modified call function by using the process.
7. The apparatus according to claim 6, wherein, the apparatus further includes a modifying module; the modifying module: for determining an interface for obtaining the storage path of the running context object of the target application; modifying the return value of the storage path obtaining interface to be a target private directory; wherein, the target private directory is a specified sub-directory of the internal private directory, and the return value of the storage path obtaining interface indicates the storage path of the target private directory file.
8. The apparatus according to claim 7, wherein: the apparatus further includes a naming module; the naming module: for determining a corresponding directory name based on the characteristic information of the target application; naming the target private directory with the directory name; the exporting of the target private directory file from the files in the internal private directory based on a preset function includes: determining the target private directory from the internal private directory based on the directory name; exporting the files in the target private directory based on the preset function; wherein, the files in the target private directory are the target private directory files.
9. The apparatus according to claim 6, wherein, the running of the target application by using the process includes using the process to execute the following steps: Determine the target installation package file corresponding to the target application from the files in the specified directory; wherein, the specified directory indicates the storage path of the installation package files of the applications to be simulated and run. Perform decompression processing on the target installation package file to obtain library files. Construct a class loader object based on the path information of the target installation package file and the path information of the library files. Use the class loader object to load the target installation package file to run the target application.
10. The device according to claim 6, wherein, the creation of the virtualized running environment further includes: Create a first type of process based on the preset framework; wherein, the first type of process is used to display the interface controls for exporting private directory files. Create a second type of process based on the preset framework; wherein, the second type of process is used to record and transfer the process information for exporting private directory files.
11. An electronic device, wherein, the electronic device includes a processor and a memory, and at least one instruction or at least one segment of program is stored in the memory, and the at least one instruction or the at least one segment of program is loaded and executed by the processor to implement the method for exporting private directory files as described in any one of claims 1-5.
12. A computer-readable storage medium, wherein, at least one instruction or at least one segment of program is stored in the storage medium, and the at least one instruction or the at least one segment of program is loaded and executed by a processor to implement the method for exporting private directory files as described in any one of claims 1-5.
13. A computer program product, wherein, the computer program product includes computer instructions, the computer instructions are stored in a computer-readable storage medium, and a processor of a computer device reads and executes the computer instructions from the computer-readable storage medium, so that the computer device executes the method for exporting private directory files as described in any one of claims 1-5.