CN105760302A - Mobile application abnormal information processing method - Google Patents

Mobile application abnormal information processing method Download PDF

Info

Publication number
CN105760302A
CN105760302A CN201610110621.4A CN201610110621A CN105760302A CN 105760302 A CN105760302 A CN 105760302A CN 201610110621 A CN201610110621 A CN 201610110621A CN 105760302 A CN105760302 A CN 105760302A
Authority
CN
China
Prior art keywords
abnormal information
application
exception
developer
abnormal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610110621.4A
Other languages
Chinese (zh)
Inventor
张安举
崔乐乐
姚民伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Software Group Co Ltd
Original Assignee
Inspur Software Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Software Group Co Ltd filed Critical Inspur Software Group Co Ltd
Priority to CN201610110621.4A priority Critical patent/CN105760302A/en
Publication of CN105760302A publication Critical patent/CN105760302A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime

Abstract

The invention provides a mobile application abnormal information processing method, which belongs to the technical field of software development, and comprises the following steps of 1) abnormal capture; 2) persistence of abnormal information; 3) sending abnormal information; capturing abnormal information which causes application crash in the running of the mobile application, selecting a fixed time point for application persistence, sending the abnormal information to a developer, and helping the developer to repair the Bug in application iteration. The method helps the mobile developer to perfect and repair the application running Bug, shows the uncontrollable crash situation to the user in a friendly form and sends the abnormal information to the developer, and helps the developer know and process the defect at the highest speed.

Description

A kind of Mobile solution abnormal information processing method
Technical field
The present invention relates to software development technique, particularly relate to a kind of Mobile solution abnormal information processing method.
Background technology
Along with the further raising of Intelligent mobile equipment performance, a lot of simple offices and recreation are directly on mobile phone Just can complete, so the mobile applications (Mobile Applications) on mobile phone has obtained significant progress.Particularly In recent years, it may be seen that the mobile applications much with epoch-making property occurs, let us is to following Mobile solution The future of program is filled with expectation.Meanwhile, the mobile applications quantity in application market enters explosive growth.Myriad applications Reaching the standard grade like the mushrooms after rain, but product quality is uneven, interface product similar, a lot of frequently occurs in running and collapses Routed (Crash) phenomenon, significantly impacts Consumer's Experience, even can lose a lot of potential user.The phenomenon of application crashes has been difficult to Entirely avoid, apply added rear developer to need monitoring application ruuning situation on a user device, in the feelings of user's " unaware " Under condition, abnormal information is cached, is sent to corresponding responsible person, it is ensured that during application upgrading next time, repair Bug.
Abnormal mechanism (Exceptional Handling) refers to after mistake occurs in program, and how program processes.Specifically For, abnormal mechanism provides the escape way that program exits.After there is mistake, the flow process that program performs changes, journey The control right transfer of sequence is to exception handler.When, after an exception of dishing out in program, program causes abnormal code from program Place jumps out, and the detection of JAVA virtual machine is found and the catch block processing this exception of try keyword match, if it is found, will control Power sends to the code in catch block, then proceedes to down perform program, occurs abnormal code again to be held in try block OK.Without finding the catch block processing this exception, it is performed the institute with current thread at all of finally block code After the uncaughtException method of the ThreadGroup belonged to is called, runs into abnormal current thread and be aborted.
Summary of the invention
In order to solve this problem, the present invention proposes a kind of Mobile solution abnormal information processing method, is processed by emphasis different Chang Wufa process, causes the operation after program determination.
The present invention includes:
1) exception catching;
2) abnormal information persistence;
3) abnormal information sends;
During capture Mobile solution runs, cause the abnormal information of application crashes, select the set time to put different application persistence Often information is sent to developer, helps developer to repair Bug in application iteration.
Exception catching:
Self-defined capture Application global abnormal;After running into the exception that software does not capture, system can eject one and write from memory The positive closing dialog box recognized.
Abnormal information persistence:
The interception behavior of abnormality processing, it is simply that judge whether intercepted method call exists exception, if it is present pass through Utils.Log method is by exception record to daily record, and at bottom, Utils.Log is then to use log4net to realize daily record note Record.
Transmission abnormal information:
After the success of abnormal information persistence, wait that application next time runs and this abnormal information is responsible for application with the form of annex People sends, and may select mail herein and sends, or sent to server by interface, is described herein as abnormal information with Email attachment Form is transmitted directly to the mode of corresponding director.
The beneficial effect that inventive technique scheme is brought
Help Mobile Development person to improve and repair application to run Bug, by uncontrollable collapse case with friendly form to user Show and abnormal information be sent to developer, help developer know with prestissimo and process defect.
Detailed description of the invention
(1) catch the exception information
Functional Design:
Self-defined capture Application global abnormal.After running into the exception that software does not capture, system can eject this and write from memory The positive closing dialog box recognized.
We are certainly not intended to user and see this phenomenon, and the reparation to our bug also has no to help.I It is desirable that software has an overall exception catching device, when occur one we do not find exception time, capture this Exception also does subsequent treatment.
Next we just realize this mechanism, but first we still understand following two class: Android.app.Application and java.lang.Thread.UncaughtExceptionHandler.
Application: be used for managing the global state of application program.The Application meeting when application program launching First create, the most just according to circumstances (Intent) corresponding Activity and Service can be started.Will be certainly in this example The Application of definition reinforcement version registers the processor that do not catchs the exception.
Thread.UncaughtExceptionHandler: thread does not catchs the exception processor, be used for processing do not capture different Often.Do not catch the exception if program occurs in that, positive closing dialog box in acquiescence meeting ejection system.We need to realize this and connect Mouthful, and be registered as program is given tacit consent to the process that do not catchs the exception.When so occurring when not catching the exception, it is possible to do some personalized Abnormality processing operation.
CrashHandler.java achieves Thread.UncaughtExceptionHandler, and code is as follows:
package com.scott.crash;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Environment;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
/**
* UncaughtException processes class, when program occurs Uncaught exception when, has such to carry out takeover process, And record transmission error reporting.
*
* @author user
*
*/
public class CrashHandler implements UncaughtExceptionHandler {
public static final String TAG = "CrashHandler";
The UncaughtException of // system default processes class
private Thread.UncaughtExceptionHandler mDefaultHandler;
//CrashHandler example
private static CrashHandler INSTANCE = new CrashHandler();
The Context object of // program
private Context mContext;
// for storing device information and abnormal information
private Map<String, String> infos = new HashMap<String, String>();
// be used for formatting the date, as a part for journal file name
private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH- mm-ss");
/ * * guarantee only one of which CrashHandler example */
private CrashHandler() {
}
/ * * obtains CrashHandler example, and singleton pattern */
public static CrashHandler getInstance() {
return INSTANCE;
}
/**
* initialize
*
* @param context
*/
public void init(Context context) {
mContext = context;
The UncaughtException processor of // acquisition system default
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
// default processor that this CrashHandler is program is set
Thread.setDefaultUncaughtExceptionHandler(this);
}
/**
* can proceed to this function process when UncaughtException occurs
*/
@Override
public void uncaughtException(Thread thread, Throwable ex) {
if (!handleException(ex) && mDefaultHandler != null) {
If // user does not process, the exception handler of system default is allowed to process
mDefaultHandler.uncaughtException(thread, ex);
} else {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
Log.e(TAG, "error : ", e);
}
// quit a program
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
}
}
/**
The most self-defined error handle, collects the operations such as error message transmission error reporting and all completes at this.
*
* @param ex
*@return true: if having processed this abnormal information;Otherwise return false.
*/
private boolean handleException(Throwable ex) {
if (ex == null) {
return false;
}
// use Toast to show abnormal information
new Thread() {
@Override
public void run() {
Looper.prepare();
Toast.makeText (mContext, " is sorry, and program occurs abnormal, i.e. will move out. ", Toast.LENGTH_LONG).show();
Looper.loop();
}
}.start();
// collecting device parameter information
collectDeviceInfo(mContext);
// preserve journal file
saveCrashInfo2File(ex);
return true;
}
/**
* collecting device parameter information
* @param ctx
*/
public void collectDeviceInfo(Context ctx) {
try {
PackageManager pm = ctx.getPackageManager();
PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
if (pi != null) {
String versionName = pi.versionName == null ? "null" : pi.versionName;
String versionCode = pi.versionCode + "";
infos.put("versionName", versionName);
infos.put("versionCode", versionCode);
}
} catch (NameNotFoundException e) {
Log.e(TAG, "an error occured when collect package info", e);
}
Field[] fields = Build.class.getDeclaredFields();
for (Field field : fields) {
try {
field.setAccessible(true);
infos.put(field.getName(), field.get(null).toString());
Log.d(TAG, field.getName() + " : " + field.get(null));
} catch (Exception e) {
Log.e(TAG, "an error occured when collect crash info", e);
}
}
}
/**
* error message is preserved in file
*
* @param ex
*@return returns file name, is easy to transfer the file to server
*/
private String saveCrashInfo2File(Throwable ex) {
StringBuffer sb = new StringBuffer();
for (Map.Entry<String, String> entry : infos.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
sb.append(key + "=" + value + "\n");
}
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
Throwable cause = ex.getCause();
while (cause != null) {
cause.printStackTrace(printWriter);
cause = cause.getCause();
}
printWriter.close();
String result = writer.toString();
sb.append(result);
try {
long timestamp = System.currentTimeMillis();
String time = formatter.format(new Date());
String fileName = "crash-" + time + "-" + timestamp + ".log";
if (Environment.getExternalStorageState().equals (Environment.MEDIA_MOUNTED)) {
String path = "/sdcard/crash/";
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
FileOutputStream fos = new FileOutputStream(path + fileName);
fos.write(sb.toString().getBytes());
fos.close();
}
return fileName;
} catch (Exception e) {
Log.e(TAG, "an error occured while writing file...", e);
}
return null;
}
}
(2) abnormal information persistence
Functional Design:
The interception behavior of abnormality processing realizes the simplest, it is simply that judge whether intercepted method call exists exception, if Exist, then by Utils.Log method by exception record to daily record, and at bottom, Utils.Log is then to use log4net Realize log recording.Abnormality processing intercepts the Invoke method of behavior and is accomplished by
/// <summary>
///by realizing the method intercepts and calls and perform required interception behavior.
/// </summary>
///<param name="input">call input information during interception target.</param>
///<param name="getNext">the trust of next interception behavior is obtained by behavioral chain.</param>
///<returns>the return information that obtains from interception target.</returns>
public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
{
var methodReturn = getNext().Invoke(input, getNext);
if (methodReturn.Exception != null)
{
Utils.Log(methodReturn.Exception);
}
return methodReturn;
}
(3) abnormal information is sent
Functional Design:
After the success of abnormal information persistence, wait that application next time runs and this abnormal information is responsible for application with the form of annex People sends, and may select mail herein and sends, or sent to server by interface, is described herein as abnormal information with Email attachment Form is transmitted directly to the mode of corresponding director.Note: mobile device sends mail to be needed by inquiry user unified.Code is such as Under:
Intent email = new Intent(android.content.Intent.ACTION_SEND);
// annex
File file = new File(Environment.getExternalStorageDirectory().getPath() + File.separator + "simplenote"+ File.separator+"note.xml");
// mail transmission types: the mail of band annex
email.setType("application/octet-stream");
// e-mail recipient (array can be multidigit recipient)
String[] emailReciver = new String[]{"auther@inspur.com","456@163.com"};
String emailTitle=" XX moves project abnormal information ";
String emailContent=" details see appendix ";
// addresses of items of mail is set
email.putExtra(android.content.Intent.EXTRA_EMAIL, emailReciver);
// mail header is set
email.putExtra(android.content.Intent.EXTRA_SUBJECT, emailTitle);
// content of transmission is set
email.putExtra(android.content.Intent.EXTRA_TEXT, emailContent);
// annex
email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
The mailing system of // calling system
StartActivity (Intent.createChooser (email, " mail please be select to send software "));.

Claims (4)

1. a Mobile solution abnormal information processing method, it is characterised in that include
1) exception catching;
2) abnormal information persistence;
3) abnormal information sends;
During capture Mobile solution runs, cause the abnormal information of application crashes, select the set time to put different application persistence Often information is sent to developer, helps developer to repair Bug in application iteration.
Method the most according to claim 1, it is characterised in that exception catching:
Self-defined capture Application global abnormal;After running into the exception that software does not capture, system can eject one and write from memory The positive closing dialog box recognized.
Method the most according to claim 2, it is characterised in that abnormal information persistence:
The interception behavior of abnormality processing, it is simply that judge whether intercepted method call exists exception, if it is present pass through Utils.Log method is by exception record to daily record, and at bottom, Utils.Log is then to use log4net to realize daily record note Record.
Method the most according to claim 3, it is characterised in that transmission abnormal information:
After the success of abnormal information persistence, wait that application next time runs and this abnormal information is responsible for application with the form of annex People sends, and may select mail herein and sends, or sent to server by interface, is described herein as abnormal information with Email attachment Form is transmitted directly to the mode of corresponding director.
CN201610110621.4A 2016-02-29 2016-02-29 Mobile application abnormal information processing method Pending CN105760302A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610110621.4A CN105760302A (en) 2016-02-29 2016-02-29 Mobile application abnormal information processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610110621.4A CN105760302A (en) 2016-02-29 2016-02-29 Mobile application abnormal information processing method

Publications (1)

Publication Number Publication Date
CN105760302A true CN105760302A (en) 2016-07-13

Family

ID=56329897

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610110621.4A Pending CN105760302A (en) 2016-02-29 2016-02-29 Mobile application abnormal information processing method

Country Status (1)

Country Link
CN (1) CN105760302A (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598804A (en) * 2016-11-29 2017-04-26 武汉斗鱼网络科技有限公司 Abnormality processing method and apparatus
CN107391295A (en) * 2017-08-11 2017-11-24 东软集团股份有限公司 The processing method and processing device of application exception
CN108228446A (en) * 2016-12-14 2018-06-29 北京国双科技有限公司 A kind of software anomaly processing method and software detection device
CN108984203A (en) * 2018-06-08 2018-12-11 广东伊莱特电器有限公司 A kind of method and its system for the acquisition of Android application runtime data
CN109656773A (en) * 2017-10-12 2019-04-19 卓望数码技术(深圳)有限公司 A kind of processing frame collapsed extremely based on the application of IOS system
CN109981621A (en) * 2019-03-15 2019-07-05 厦门美图之家科技有限公司 Network request processing method and processing device
CN110287051A (en) * 2019-06-21 2019-09-27 四川盛趣时代网络科技有限公司 Active protection method based on windows exception handling
CN112685045A (en) * 2020-12-28 2021-04-20 北京达佳互联信息技术有限公司 Page source file processing method and device, electronic equipment and storage medium
CN113867999A (en) * 2021-08-30 2021-12-31 荣耀终端有限公司 Application exception handling method, terminal and computer readable storage medium
CN114756400A (en) * 2022-06-15 2022-07-15 四川新网银行股份有限公司 Application program exception handling method and system based on android system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060277442A1 (en) * 2005-06-07 2006-12-07 Microsoft Corporation Patching a mobile computing device software error
CN101770422A (en) * 2008-12-30 2010-07-07 鸿富锦精密工业(深圳)有限公司 Software bug tracking method and computer system thereof
CN102981943A (en) * 2012-10-29 2013-03-20 新浪技术(中国)有限公司 Method and system for monitoring application logs
CN104156275A (en) * 2014-06-30 2014-11-19 青岛海信移动通信技术股份有限公司 Method and device for exception handling of Android platform

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060277442A1 (en) * 2005-06-07 2006-12-07 Microsoft Corporation Patching a mobile computing device software error
CN101770422A (en) * 2008-12-30 2010-07-07 鸿富锦精密工业(深圳)有限公司 Software bug tracking method and computer system thereof
CN102981943A (en) * 2012-10-29 2013-03-20 新浪技术(中国)有限公司 Method and system for monitoring application logs
CN104156275A (en) * 2014-06-30 2014-11-19 青岛海信移动通信技术股份有限公司 Method and device for exception handling of Android platform

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598804A (en) * 2016-11-29 2017-04-26 武汉斗鱼网络科技有限公司 Abnormality processing method and apparatus
CN108228446A (en) * 2016-12-14 2018-06-29 北京国双科技有限公司 A kind of software anomaly processing method and software detection device
CN107391295A (en) * 2017-08-11 2017-11-24 东软集团股份有限公司 The processing method and processing device of application exception
CN109656773A (en) * 2017-10-12 2019-04-19 卓望数码技术(深圳)有限公司 A kind of processing frame collapsed extremely based on the application of IOS system
CN108984203A (en) * 2018-06-08 2018-12-11 广东伊莱特电器有限公司 A kind of method and its system for the acquisition of Android application runtime data
CN109981621A (en) * 2019-03-15 2019-07-05 厦门美图之家科技有限公司 Network request processing method and processing device
CN110287051A (en) * 2019-06-21 2019-09-27 四川盛趣时代网络科技有限公司 Active protection method based on windows exception handling
CN112685045A (en) * 2020-12-28 2021-04-20 北京达佳互联信息技术有限公司 Page source file processing method and device, electronic equipment and storage medium
CN113867999A (en) * 2021-08-30 2021-12-31 荣耀终端有限公司 Application exception handling method, terminal and computer readable storage medium
CN114756400A (en) * 2022-06-15 2022-07-15 四川新网银行股份有限公司 Application program exception handling method and system based on android system
CN114756400B (en) * 2022-06-15 2022-08-26 四川新网银行股份有限公司 Application program exception handling method and system based on android system

Similar Documents

Publication Publication Date Title
CN105760302A (en) Mobile application abnormal information processing method
US10915382B2 (en) Event-driven serverless function orchestration
US9329983B2 (en) Computer program testing
WO2020147462A1 (en) Recovery from application anomaly
US9836343B2 (en) Framework for user-mode crash reporting
US8601323B2 (en) Advanced management of runtime errors
CN103809967A (en) Application and data removal system
JP2016534479A5 (en)
CN108134708B (en) Method and device for monitoring third-party interface
CN104205109A (en) Persistent and resilient worker processes
US20180322030A1 (en) Conditional debugging of server-side production code
CN104166575B (en) The decision method and device of startup item handling result
US8694831B2 (en) Automatic bug reporting tool
CN115292073B (en) Method for sending android application file on Linux platform
US20150120374A1 (en) Automation of customer relationship management (crm) tasks responsive to electronic communications
US8151251B2 (en) e-Profiler: dynamic profiling and auditing framework
CN113779574A (en) APT detection method based on context behavior analysis
CN108121633A (en) Exception catching method and device
US20060101099A1 (en) Method and system to provide files to a client computer
CN113127775B (en) Page loading method, device, equipment and storage medium
Lee et al. All about activity injection: threats, semantics, and detection
US7752504B2 (en) System diagnostics with dynamic contextual information of events
EP2515503A1 (en) Method of managing data sent to a secure element via a HTTP response message
CN116028310A (en) Performance analysis method and device for application program
US8522256B2 (en) Hosting non-messaging workflows in a messaging host

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20160713

WD01 Invention patent application deemed withdrawn after publication