Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
In order to explain the technical solution of the present application, the following description will be given by way of specific examples.
Example one
Referring to fig. 1, a method for optimizing a system according to an embodiment of the present application is described below, where the method according to the embodiment of the present application includes:
instep 101, after system startup, the unique identifier UID of the application data directory is obtained.
In this embodiment of the application, the system may be an Android operating system (Android operating system), or an operating system similar to the Android operating system, and the operating system may be run on a smart phone, a tablet computer, a smart television, a router, or other terminal devices. The system starting means that the terminal equipment performs power-on operation when receiving a starting-up instruction, and then the operating system is loaded into the memory to operate, wherein the starting-up instruction can be sent out by a user through operating a starting-up key on the terminal equipment.
In the Android operating system, one user UID uniquely identifies one application. The application is assigned a unique UID at installation, and the UID remains unchanged for the duration of the application on the device. Each application corresponds to an application data directory, the application data directory is usually a file directory/data/data/< package name > on the system, and the application data directory is used for storing a setting file, a database file of the application, data generated during the running of the application, and the like. For example, the WeChat application on the terminal device is installed under a/data/app/< packet name > file directory corresponding to WeChat, and data (including temporary data and permanent data) generated by the WeChat application in the running process is saved in the/data/data/< packet name > file directory corresponding to WeChat. The entry is typically determined by the application provider, for example, the package name of the WeChat is "com. Since the package name may have different expressions, the specific expression of the package name is not limited herein. When an application is installed, the system will create an application data directory, which the system will assign to the same UID as its associated application. In the running process of the application, the application data directory for storing the application running data can be identified in a UID (user identification) mode. The application data directory is used for storing data generated by the application in operation. Applications often need to read data from an application data directory and store data generated during the operation of the application in the application data directory during the operation. For example, chat records generated in the process of chatting by using the WeChat are stored in a data directory of the WeChat application, and when a user sends an instruction for viewing the chat records to the WeChat application, the WeChat application reads relevant data of an application data directory associated with the WeChat application and displays the data on a UI (user interface) for the user to view.
Instep 102, it is determined whether the UID of the application data directory is abnormal.
Instep 103, if the UID of the application data directory is abnormal, the UID of the application associated with the application data directory is acquired, and the UID of the application data directory is replaced with the UID of the application.
In an embodiment of the present application, if the UID of the application data directory is abnormal, for example, the UID of the application data directory is different from the UID of its associated application. Since the application is by identifying the application data directory having the same UID as itself as its own application data directory. When the UID of the application data directory is different from the UID of the associated application, the application cannot find the own application data directory, so that the data in the application data directory associated with the application cannot be operated, and the UID of the application data directory is considered to be abnormal. And repairing the application data directory by acquiring the UID of the application associated with the application data directory and then replacing the UID of the application data directory with the UID of the application.
According to the method and the device, after the system is started every time and before the application program is started, whether the UID of the application data directory is abnormal or not is detected, if the UID of the application related to the application data directory is abnormal, the UID of the application related to the application data directory is obtained, and the UID of the application data directory is replaced by the UID of the application, so that the UID of the abnormal application data directory can be repaired when the system is started every time, the probability of abnormality when a user starts the application is reduced, the problem that the operation of the application is broken down due to the fact that the related application is started before the UID of the application data directory is not repaired is solved, and the stability of the system is enhanced.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Example two
Fig. 2 is a schematic flow chart of another system optimization method provided in the embodiment of the present application, and as shown in the figure, the method may include the following steps:
instep 201, after the system is started, the UID of the application data directory is acquired through an installd process.
In the embodiment of the application, the installd is a native daemon (daemon), and the installd has root authority and can directly manage the package installation transaction. For example, installd may support installing, uninstalling applications, deleting apks, creating an application data directory, changing the name of an application data directory, and the UID of an application data directory. installd executes the relevant commands by listening to a local socket, which is created by specifying the service attributes in an init. If a socket is connected in, the command character string is read through the socket, and then the command is executed.
Instep 202, determining whether the UID of the application data directory is the same as the UID of the instant process;
instep 203, if the UID of the application data directory is the same as the UID of the installd process, it is determined that the UID of the application data directory is abnormal.
In the embodiment of the application, when an install creates an application data directory for an application, the UID of the application data directory being created is set as the UID of the install process, and after the creation of the application data directory is completed, the UID of the application data directory is modified into the UID of the application. In practice, it is found that the installd process operates on the application, such as installing the application. When an installd process is operating on an application data directory (e.g., creating an application data directory for an application). If a sudden power loss event occurs. Since the operation of the instruction process on the application data directory is not completed, the UID of the application data directory is actually the UID of the instruction process, not the UID of the application associated with the application data directory. When the user starts the application after the system is started again, the application searches the corresponding application data directory through the UID, and the UID of the application data directory associated with the application is the UID of the installd process, so that the application cannot operate the data in the application data directory because the associated application data directory cannot be searched, and the application operation is abnormal.
Instep 204, if the UID of the application data directory is abnormal, the UID of the application associated with the application data directory is acquired, and the UID of the application data directory is replaced with the UID of the application.
In the embodiment of the application, after the system is started, the install process detects whether an application data directory with the same UID as that of the install process exists in the application data directory, and if the application data directory with the same UID as that of the install process exists, the UID of the application data directory is considered to be abnormal, and the application program cannot operate the application data directory. In this embodiment, the problem of UID abnormality of the application data directory may be repaired by acquiring the UID of the application associated with the application data directory and replacing the UID of the application data directory with the UID of the application.
As can be seen from the above, in this embodiment, when the terminal powers on and starts the operating system, the daemon process is started and the UIDs of all application data directories in the system are detected through the isntald process, and if it is detected that the UID of the application data directory is the same as the UID of the installd process, the UID is repaired by obtaining the UID of the application associated with the application data directory to replace the UID of the application data directory. The UID of the application data directory is detected by using the installd process every time the computer is started, so that the problem that the application cannot operate the data directory due to unexpected power failure is solved, and the stability of the system is enhanced.
Optionally, the obtaining the UID of the application associated with the application data directory includes:
acquiring a package name in the application data directory;
and acquiring the UID of the application associated with the application data directory based on the package name.
In this embodiment of the application, after the installd detects the application data directory with the UID abnormal, the packet name of the application may be obtained through the path information of the application data directory, for example, the path of the application data directory is: and the packet name of the application data directory can be obtained by intercepting the name of the lowest level directory in the path and assigning the intercepted name of the lowest level directory to the character string variable.
The packagemangenerrice service in the Android system is responsible for installation, uninstallation, optimization and UID query of various APK packages, and optionally, the UID of the application designated by the package name can be queried from the packagemangenerrice service through package name information. After the UID of the application is inquired by the PackageManger Serivce, the UID is transmitted to the inside thread process, and then the inside thread process carries out the operation of replacing the UID of the application data directory with the inquired UID of the application with the UID abnormality, thereby finishing the UID repairing work.
According to the embodiment of the application, the package name of the application data directory with the UID abnormal is obtained through the inside, the UID of the application is obtained from the packagemangerSerivce based on the package name, the UID abnormal repairing work after the startup is finished in a mode of cooperation of the inside and the packagemangerSerivce, and the repairing mode has the advantages of being few in occupied system resources, high in repairing speed, free of influence on startup efficiency and the like. And the UID abnormity is repaired when the computer is started, so that the problem that a user does not know how to solve when the application cannot operate the application data directory is avoided, and the user experience is improved.
Optionally, obtaining the UID of the application associated with the application data directory, and replacing the UID of the application data directory with the UID of the application comprises:
searching an application installation directory corresponding to the application data directory;
and if the application installation directory corresponding to the application data directory is found, acquiring the UID of the application associated with the application data directory from the installation directory, and replacing the UID of the application data directory with the UID of the application.
After the instruction insertion process obtains the package name of the application data directory with the abnormal UID, the package name can be searched in the application installation directory (namely/data/app path), if the package name is found, the application is the application installed on the terminal device, UID information of the application is found in the application installation directory, the found UID of the application is transmitted to the instruction insertion process, and the found UID of the application is replaced by the UID of the application data directory with the abnormal UID through the intelligent insertion process, so that UID repairing work is completed.
Optionally, if the application installation directory corresponding to the application data directory is not found, the UID of the application associated with the application data directory is not acquired, and the application data directory is deleted.
In the embodiment of the application, after obtaining the package name of the application data directory with the abnormal UID, the installd process searches the package name under the application installation directory, and if the application installation directory corresponding to the application data directory is found, it indicates that the application may have been unloaded, and since the application has been unloaded, that is, an event for starting the application does not occur, there is no need to repair the UID of the application data directory, and therefore, in the case of finding the application installation directory corresponding to the application data directory, the UID of the application associated with the application data directory is not obtained.
Optionally, the application data directory may be a part that is unexpectedly powered off during the process of unloading the application without completely unloading the application, because the application installation directory corresponding to the application data directory is not found to indicate that the application may have been unloaded. Therefore, when the application installation catalog corresponding to the application data catalog cannot be found, the application data catalog is deleted, and the storage space of the terminal is saved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
EXAMPLE III
In this embodiment, based on the first embodiment or the second embodiment, fig. 3 is a schematic flowchart of another method for optimizing a system according to an embodiment of the present application, where as shown in the figure, the method may include the following steps after replacing the UID of the application data directory with the UID of the application:
step 301, starting the application;
step 302, judging whether the starting of the application is abnormal or not;
step 303, if the application is abnormally started, sending a prompt message to a user or restarting the system.
In this embodiment, after the UID change operation is performed on the application data directory with the UID exception, an operation of starting the application may be automatically performed, for example, when the system detects that the installd performs an operation of replacing the UID of the application data directory, a start instruction of the application is automatically triggered, the start mode may be foreground start or background start, preferably a background start mode is adopted, and after the application is started, whether an exception occurs is determined, and the exception may be, for example, receiving an error report message of the application, or automatically exiting the application. And when detecting that the application starting is abnormal, sending prompt information to a user. Optionally, if an application is started to have an exception after the UID of the application data directory is replaced with the UID of the application, the user may be automatically prompted to restart the system, and after the system is restarted,step 101 and step 103 in embodiment one or step 201 and step 204 in embodiment two are performed here. After thestep 101 and 103 in the first embodiment or thestep 201 and 204 in the second embodiment are re-executed after the restart, if the application is still abnormal, a prompt message is sent to the user to suggest the user to adopt other solutions, for example, reinstalling the application or performing an upgrade operation on the application.
According to the embodiment of the application, after the UID repairing operation is executed, whether the repairing is successful or not is detected in an automatic application starting mode, and if the repairing is detected to be failed, the repairing operation is executed again after the system is restarted. And the success rate of UID repair is further improved.
Example four
An embodiment of the present application further provides an optimization apparatus of a system, as shown in fig. 3, anoptimization apparatus 400 in the embodiment of the present application includes:
aUID obtaining unit 401, configured to obtain a unique identifier UID of the application data directory after the system is started;
aUID detection unit 402 configured to determine whether a UID of the application data directory is abnormal;
aUID repair unit 403, configured to, if the UID of the application data directory is abnormal, obtain the UID of the application associated with the application data directory, and replace the UID of the application data directory with the UID of the application.
Optionally, the obtaining the UID of the application data directory includes:
and acquiring the UID of the application data directory through an installd process.
Optionally, the determining whether the UID of the application data directory is abnormal includes:
judging whether the UID of the application data directory is the same as the UID of the installd process;
and if the UID of the application data directory is the same as the UID of the installd process, determining that the UID of the application data directory is abnormal.
Optionally, theUID repair unit 403 includes:
the searching subunit is used for searching the application installation catalog corresponding to the application data catalog;
and the replacing subunit is used for acquiring the UID of the application associated with the application data directory from the installation directory if the application installation directory corresponding to the application data directory is found, and replacing the UID of the application data directory with the UID of the application.
Optionally, theUID repair unit 403 further includes:
and the deleting subunit is used for not acquiring the UID of the application associated with the application data directory and deleting the application data directory if the application installation directory corresponding to the application data directory is not found.
Optionally, theoptimization apparatus 400 further includes:
a detection unit for starting the application;
judging whether the starting of the application is abnormal or not;
and if the application is abnormally started, sending a prompt message to a user or restarting the system.
By using the optimization device of the system in the embodiment of the application, after the system is started each time and before an application program is started, the embodiment of the application detects whether the UID of the application data directory is abnormal or not, if the UID of the application related to the application data directory is abnormal, the UID of the application related to the application data directory is obtained, and the UID of the application data directory is replaced by the UID of the application, so that the UID of the abnormal application data directory can be repaired each time the system is started, the problem that the operation of the application is crashed due to the fact that the related application is started before the UID of the application data directory is not repaired is solved, the probability of the abnormality when a user starts the application is reduced, and the stability of the system is.
EXAMPLE five
An embodiment of the present application provides a mobile terminal, please refer to fig. 5, where the mobile terminal in the embodiment of the present application includes: amemory 501, one or more processors 502 (only one shown in fig. 5), and a computer program stored on thememory 501 and executable on the processors. Wherein: thememory 501 is used for storing software programs and modules, and theprocessor 502 executes various functional applications and data processing by running the software programs and units stored in thememory 401, so as to acquire resources corresponding to the preset events. Specifically, theprocessor 502 realizes the following steps by running the above-mentioned computer program stored in the memory 501:
after the system is started, acquiring a unique identifier UID of an application data directory;
judging whether the UID of the application data directory is abnormal or not;
and if the UID of the application data directory is abnormal, acquiring the UID of the application associated with the application data directory, and replacing the UID of the application data directory with the UID of the application.
Given the first possible embodiment described above, in a second possible embodiment provided on the basis of the first possible embodiment,
the obtaining of the UID of the application data directory comprises:
and acquiring the UID of the application data directory through an installd process.
In a third possible embodiment provided on the basis of the second possible embodiment described above,
the judging whether the UID of the application data directory is abnormal comprises the following steps:
judging whether the UID of the application data directory is the same as the UID of the installd process;
and if the UID of the application data directory is the same as the UID of the installd process, determining that the UID of the application data directory is abnormal.
In a fourth possible embodiment provided on the basis of the first possible embodiment described above,
the obtaining the UID of the application associated with the application data directory comprises:
acquiring a package name in the application data directory;
and acquiring the UID of the application associated with the application data directory based on the package name.
In a fifth possible embodiment provided on the basis of the first possible embodiment described above,
obtaining the UID of the application associated with the application data directory, and replacing the UID of the application data directory with the UID of the application comprises:
searching an application installation directory corresponding to the application data directory;
if the application installation directory corresponding to the application data directory is found, acquiring the UID of the application associated with the application data directory from the installation directory, and replacing the UID of the application data directory with the UID of the application;
and if the application installation directory corresponding to the application data directory is not found, not acquiring the UID of the application associated with the application data directory, and deleting the application data directory.
In a seventh possible embodiment provided on the basis of the first possible embodiment described above,
after replacing the UID of the application data directory with the UID of the application, further comprising:
starting the application;
judging whether the starting of the application is abnormal or not;
and if the application is abnormally started, sending a prompt message to a user or restarting the system.
Further, as shown in fig. 5, the mobile terminal 5 may further include: one or more input devices 503 (only one shown in fig. 5) and one or more output devices 504 (only one shown in fig. 5). Thememory 501,processor 502,input device 503, and output device 404 are connected by a bus 405.
It should be understood that the mobile terminal 5 may be a computing device such as a smart phone, a tablet computer, etc. TheProcessor 502 may be a Central Processing Unit (CPU), or other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Theinput device 503 may include a keyboard, a touch pad, a fingerprint sensor (for collecting fingerprint information of a user and direction information of the fingerprint), a microphone, etc., and theoutput device 504 may include a screen, a speaker, etc.
Memory 501 may include both read-only memory and random access memory and provides instructions and data toprocessor 502. Some or all of thememory 501 may also include non-volatile random access memory. For example, thememory 501 may also store device type information.
As can be seen from the above, in the embodiment of the present application, before an application program is started, whether the UID of the application data directory is abnormal is detected, if the abnormality occurs, the UID of the application associated with the application data directory is obtained, and the UID of the application data directory is replaced with the UID of the application, so that the UID of the abnormal application data directory can be repaired at each startup, the problem of application operation crash caused by starting the associated application before the UID abnormality of the application data directory is not repaired is avoided, and thus the stability of the system is enhanced.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned functions may be distributed as different functional units and modules according to needs, that is, the internal structure of the apparatus may be divided into different functional units or modules to implement all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described system embodiments are merely illustrative, and for example, the division of the above-described modules or units is only one logical functional division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The integrated unit may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a separate product. Based on such understanding, all or part of the flow in the method of the embodiments described above may be implemented by a computer program, which may be stored in a computer readable storage medium and used by a processor to implement the steps of the embodiments of the methods described above. The computer program includes computer program code, and the computer program code may be in a source code form, an object code form, an executable file or some intermediate form. The computer readable medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signal, telecommunication signal, software distribution medium, etc. It should be noted that the computer readable medium described above may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media excludes electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.