Disclosure of Invention
In view of the above deficiencies of the prior art, the present invention is directed to a method for reporting a log by a client and an electronic device, and aims to solve the problems of complicated result reproduction steps and low efficiency of the existing client.
The technical scheme of the invention is as follows:
a method for reporting logs by a client comprises the following steps:
A. writing the operation behavior of a user on the client into a local file, and encrypting the local file to generate an encrypted file;
B. uploading the encrypted file to a background server and storing the encrypted file in the background server;
C. downloading the encrypted file from a background server and decrypting the encrypted file;
D. and acquiring the decrypted file, and analyzing the operation behavior of the user on the client according to the decrypted file.
Preferably, step a is preceded by:
and acquiring the permission of writing the operation behavior of the user on the client into the local file in advance.
Preferably, the step a specifically includes:
a1, judging whether a local file exists, if so, executing the step A2, and if not, switching to the step A3;
a2, directly writing the operation behavior of the user on the client into a local file, and encrypting the local file to generate an encrypted file;
a3, creating a local file, naming the local file by the current date, writing the operation behavior of the user on the client into the local file, and encrypting the local file to generate an encrypted file.
Preferably, the writing the operation behavior of the user on the client into the local file in the step a specifically includes:
embedding points in each behavior method of the client in advance;
and when the behavior method is triggered, writing a corresponding flag into a local file.
Preferably, the step a is encrypted by using an MD5 encryption method.
Preferably, the step B specifically includes:
b1, detecting the current network environment of the client, and entering the step B2 when the client is in the WiFi environment;
b2, uploading the encrypted file to a background server, and storing the file in the background server.
Preferably, in the step a, a storage period is set for the local file.
The present invention also provides an electronic device, comprising:
a processor adapted to implement the instructions, an
A storage device adapted to store a plurality of instructions, the instructions adapted to be loaded and executed by a processor, adapted to implement the instructions to:
writing the operation behavior of a user on the client into a local file, and encrypting the local file to generate an encrypted file;
uploading the encrypted file to a background server and storing the encrypted file in the background server;
downloading the encrypted file from a background server and decrypting the encrypted file;
and acquiring the decrypted file, and analyzing the operation behavior of the user on the client according to the decrypted file.
Preferably, a storage period is set for the local file.
Preferably, the encryption is performed by using an MD5 encryption method.
Has the advantages that: by the method and the electronic equipment provided by the invention, a user does not need to repeat the previous operation on the client and then reproduce the result, so that a complicated flow is omitted, the time is saved, the efficiency is improved, the robustness of the client is improved, and the abnormity appearing on the client is solved in an auxiliary manner.
Detailed Description
The invention provides a method for reporting a log by a client and an electronic device, and the invention is further described in detail below in order to make the purpose, technical scheme and effect of the invention clearer and more clear and definite. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a flowchart of a preferred embodiment of a method for reporting a log by a client according to the present invention, which includes the steps of:
s1, writing the operation behavior of the user to the client into the local file, and encrypting the local file to generate an encrypted file;
s2, uploading the encrypted file to a background server and storing the encrypted file in the background server;
s3, downloading the encrypted file from the background server and decrypting the encrypted file;
and S4, acquiring the decrypted file, and analyzing the operation behavior of the user on the client according to the decrypted file.
By the method, the encrypted file can be downloaded through the background server, the user operation behavior is obtained after the encrypted file is decrypted, and the previous operation of the user on the client can be analyzed through the operation behavior. Therefore, the user can reproduce the operation result without repeating the operation on the client before, thereby greatly saving the time and improving the working efficiency.
Preferably, step S1 is preceded by:
and acquiring the permission of writing the operation behavior of the user on the client into the local file in advance.
Before the client writes the operation behavior into the local file, the client needs to acquire the written authority in advance. For example, if an App needs to apply for a Camera right, when the App needs to use the Camera, if the App is called for the first time, because the App is not registered in the Camera service, at this time, the Camera service calls the AppOpsManager to access AppOpsService, sends a right application request, pops up a unified right application dialog box, registers a right to be used, for example, checking a right required by a user in the dialog box, and determines the right. If the rights are obtained, the requested service is opened, and if the requested service is denied, the service is denied to the APP. The opportunity is similar to service interception of APP without permission when AppOpsManager identifies, if the permission for response is set in Setting, corresponding permission operation persistent files/data/system/appops.
Preferably, the step S1 specifically includes:
s11, judging whether a local file exists, if so, executing a step S12, otherwise, turning to a step S13;
s12, directly writing the operation behavior of the user on the client into the local file, and encrypting the local file to generate an encrypted file;
s13, creating a local file, naming the local file by the current date, writing the operation behavior of the user on the client into the local file, and encrypting the local file to generate an encrypted file.
In the step S11, it is determined whether a local file exists, and if so, the step S12 is executed; if no local file exists, the process proceeds to step S13.
In step S12, when a local file exists, the operation behavior of the user on the client is written into the local file, and then the local file is encrypted to generate an encrypted file. For example, the behavior of the user operating the client specifically includes: scanning express items to enter a station; putting the express on the shelf; and (6) signing for the express mail. Then, the three behaviors are directly written into a local file, after the writing is finished, the content of the file is firstly encrypted, the encryption is for the safety of the content, and other users can directly read the content of the file after the file is prevented from being lost. And after the content of the file is encrypted, encrypting the file to generate an encrypted file.
In step S13, when there is no local file, a local file is created first, and the local file is named with the current date. For example, the named file names are: 2017.12.05. after the creation and naming are completed, the operation behavior of the user on the client side is written into a local file, the content of the file is encrypted, and after the encryption is completed, the file is encrypted to generate an encrypted file.
Preferably, in step S1, a saving period is set for the local file.
After the local file is created, a save period is set. For example, if the set saving period is seven days, the local file is saved for seven days when the local file is created, and the local file is automatically cleaned after seven days. If the previous local file creation time is 2017.12.01, the previous local file is automatically destroyed at 2017.12.08, and if the current date is 2017.12.09, the local file needs to be created; if the current date is 2017.12.07, then no local file need be created. Therefore, the file can be ensured to be always kept in the storage period, the space is effectively saved, and the robustness of the program is facilitated.
Preferably, the writing, in the step S1, the operation behavior of the user on the client into the local file specifically includes:
s11', pre-embedding points for each behavior method of the client;
s12', when the behavior method is triggered, writing the corresponding flag into the local file.
In the steps S11 'and S12', each behavior method of the client is pre-doted, and when the corresponding behavior method is triggered, the corresponding flag (i.e., identifier) is written into the local file. After the writing is completed, the subsequent steps are performed.
The buried point refers to a related technology for capturing, processing and transmitting specific user behaviors or events and an implementation process thereof.
For example, a user signs an express through a client, before that, behavior methods such as signing the express, putting the express on shelf, signing the express and the like are embedded (namely, corresponding flag is embedded in the corresponding behavior method), when the user signs the express through the client, the corresponding flag is written into a local file and encrypted, and an encrypted file is generated.
Preferably, the step S2 specifically includes:
s21, detecting the current network environment of the client, and entering the step S22 when the client is in the WiFi environment;
and S22, uploading the encrypted file to a background server, and storing the encrypted file in the background server.
The client side is provided with an interface device which can acquire a comparison account number, after the client side enters the client side, the local account number is compared with the comparison account number acquired by the interface device, and if the conditions are met, the encrypted file meeting the date is uploaded in a WiFi environment. Therefore, the condition of uploading a large amount of irrelevant data can be avoided, the pertinence is better achieved, and meanwhile, the uniqueness of the account reporting is also ensured. The interface device can acquire a comparison account number, and through comparison of the comparison account number and the local account number, when the local account number meets the conditions, the encrypted file meeting the date is uploaded. The satisfaction date can be that the user presets the encrypted files meeting one of the time periods to be uploaded, for example, the time period is set to 2017.12.01-2017.12.07, and then the local files created or directly written in the time period of 2017.12.01-2017.12.07 are encrypted again and then uploaded.
In step S21, detecting the network environment where the client is located, the specific detection steps are as follows:
the broadcastreever registers with the AMS (Activity Manager service) through a Binder mechanism;
a broadcast sender sends a broadcast to the AMS through a binder mechanism;
AMS searches for BroadcastReceiver meeting corresponding conditions, namely the client is in Wifi environment, and sends the broadcast to a message circulating queue corresponding to the BroadcastReceiver (Activity under general conditions);
the message loops back to the onReceive () method in BroadcastReceiver, taking this broadcast.
The broadcast sender and the broadcast receiver belong to the message publishing and subscribing ends in the observer mode respectively, and the AMS belongs to the middle processing center. The broadcast sender and broadcast receiver are executed asynchronously, and the outgoing broadcast is not concerned with whether the receiver is receiving or not, nor is it certain when the receiver can receive it at all.
In step S22, the encrypted file meeting the condition is uploaded to the background server, and the encrypted file is stored in the background server after being received by the background server. When the user enters the APP, a background service is started by default, the account is verified (i.e., the local account mentioned in step S1 is compared with the account acquired by the interface device), and then an encrypted file meeting the conditions is selected to wait for uploading.
In step S3, the encrypted file in the background server is downloaded and actually operated on the cloud storage. Cloud storage is a new concept extended and developed on the cloud computing (cloud computing) concept, is an emerging network storage technology, and refers to a system which integrates a large number of various types of storage devices in a network through application software to cooperatively work through functions such as cluster application, network technology or distributed file system and the like, and provides data storage and service access functions to the outside. When the core of operation and processing of the cloud computing system is storage and management of a large amount of data, a large amount of storage devices need to be configured in the cloud computing system, and then the cloud computing system is converted into a cloud storage system, so that the cloud storage is the cloud computing system taking data storage and management as the core. Briefly, cloud storage is an emerging solution for putting storage resources on the cloud for human access. The user can conveniently access data at any time and any place through connecting to the cloud through any internet-connected device. When the file is uploaded to the cloud storage, the operation can be carried out on the cloud storage website.
Therefore, uploading is carried out in the WiFi network environment, on one hand, user flow can be saved, on the other hand, transmission is more stable, transmission speed is higher, and time is saved.
Preferably, in step S1, the encryption is performed by using MD5 encryption method.
The encryption specifically includes file content encryption and file encryption. The file content encryption is to encrypt the content in the file, so that in order to avoid that after the file is lost, a lawless person can directly read the content of the file, and further obtain other information, files and the like in the client. The file encryption is to encrypt the whole file, and the file encryption (i.e. the whole file encryption) can obtain a first encrypted value. When the encrypted file is uploaded, the first encrypted value also needs to be uploaded and stored in the background server, so that subsequent encrypted value verification is facilitated.
MD5 is known as Message-Digest Algorithm, fifth edition, MD5 encryption, which allows large volumes of information to be "compressed" into a secure format (i.e., a string of bytes of any length is converted into a large integer of a fixed length) before the private key is signed by digital signature software. And the MD5 encryption has the following characteristics: fixation: for data with any length, the calculated MD5 value length is fixed; easy calculation: the MD5 value is easy to calculate from the original data; resistance to modification: any change is made to the original data, even if only 1 byte is modified, the calculated MD5 value is very different; strong collision resistance: knowing the original data and its MD5 value, it is very difficult to find a data with the same MD5 value (i.e., counterfeit data).
And after the downloading is finished, decrypting the downloaded encrypted file, wherein the decryption is to decrypt the file according to the user-defined MD5 rule, and decrypt the file content according to the MD5 rule after the decryption is finished. The second encryption value is obtained by calculation when the file is decrypted by the custom MD5 rule. When the user downloads the encrypted file from the background server, the first encrypted value also needs to be downloaded. After downloading the encrypted file, decrypting to obtain the second encrypted value, and comparing the first encrypted value with the second encrypted value. And after the encrypted file is decrypted, the file content in the decrypted file obtained at this time is the operation behavior of the user on the client.
The user can directly judge whether the file is abnormal or not through the two encrypted values, and the specific judgment rule is as follows:
when the first encryption value is the same as the second encryption value, the file is stated to be unchanged and the file is safe;
when the first encryption value is different from the second encryption value, the file is described to be modified, even Trojan and virus attacks are possible, and the content of the file can be divulged.
The user may take corresponding measures according to whether the first encrypted value is the same as the second encrypted value, and when the first encrypted value is the same as the second encrypted value, the user may choose to perform the subsequent step S4, and when the first encrypted value is different from the second encrypted value, the user may first process the decrypted file obtained by decryption, for example, perform antivirus processing on the decrypted file, and then choose to perform the step S4.
In step S4, the user may directly read the operation behavior in the decrypted file, and analyze the operation behavior in combination with the specific service scenario. The user experience of the mobile client can be better optimized, the robustness of the client is improved, and bug occurring at the local client is solved in an auxiliary mode.
For example, a user puts in, puts on a shelf, and signs in an express mail through a client, and due to misoperation of the user, the circulation of the express mail is abnormal, but the user does not determine which link has a problem. At this time, the background server downloads the encrypted file and the first encrypted value, decrypts the encrypted file to obtain a second encrypted value and an operation behavior of the user on the client, and the second encrypted value and the first encrypted value are the same through comparison with the first encrypted value, which indicates that the file is not tampered and attacked by trojans. By reading the operation behavior of the user to the client, the fact that the user does not operate the express delivery on shelf due to misoperation is known, and only the express delivery is put in storage and signed for. Therefore, the user can put on the shelf again through the client, so that the circulation of the express is complete, and a closed loop is formed.
Therefore, by analyzing the operation behaviors of the user on the client, the operation behaviors of the user on the client can be determined, when necessary operation behaviors are lacked, the fact that one link is missed by mistake when the user operates the client is shown, the client can operate again at the moment, all links are complete, and a closed loop is formed.
The present invention also provides an electronic device 10, as shown in fig. 2, comprising:
a processor 110 adapted to implement instructions, an
A storage device 120 adapted to store a plurality of instructions, the instructions adapted to be loaded and executed by a processor, adapted to implement the instructions to:
writing the operation behavior of a user on the client into a local file, and encrypting the local file to generate an encrypted file;
uploading the encrypted file to a background server and storing the encrypted file in the background server;
downloading the encrypted file from a background server and decrypting the encrypted file;
and acquiring the decrypted file, and analyzing the operation behavior of the user on the client according to the decrypted file.
The processor 110 may be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), a single chip, an arm (acorn RISC machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. Also, the processor may be any conventional processor, microprocessor, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
The storage device 120, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions corresponding to the domain name dynamic switching method in the embodiment of the present invention. The processor executes various functional applications and data processing of dynamic domain name switching by running nonvolatile software programs, instructions and units stored in the storage device, that is, the domain name dynamic switching method in the above method embodiment is implemented.
Preferably, a storage period is set for the local file.
Preferably, the encryption is performed by using an MD5 encryption method.
The specific technical details of the electronic device are described in detail in the above steps, and are not described herein again.
It is to be understood that the invention is not limited to the examples described above, but that modifications and variations may be effected thereto by those of ordinary skill in the art in light of the foregoing description, and that all such modifications and variations are intended to be within the scope of the invention as defined by the appended claims.