ApplicationErrorReportpublic class ApplicationErrorReport extends Object implements android.os.ParcelableDescribes an application error.
A report has a type, which is one of
- {@link #TYPE_NONE} uninitialized instance of {@link ApplicationErrorReport}.
- {@link #TYPE_CRASH} application crash. Information about the crash
is stored in {@link #crashInfo}.
- {@link #TYPE_ANR} application not responding. Information about the
ANR is stored in {@link #anrInfo}.
- {@link #TYPE_BATTERY} user reported application is using too much
battery. Information about the battery use is stored in {@link #batteryInfo}.
- {@link #TYPE_RUNNING_SERVICE} user reported application is leaving an
unneeded serive running. Information about the battery use is stored in
{@link #runningServiceInfo}.
|
Fields Summary |
---|
static final String | SYSTEM_APPS_ERROR_RECEIVER_PROPERTY | static final String | DEFAULT_ERROR_RECEIVER_PROPERTY | public static final int | TYPE_NONEUninitialized error report. | public static final int | TYPE_CRASHAn error report about an application crash. | public static final int | TYPE_ANRAn error report about an application that's not responding. | public static final int | TYPE_BATTERYAn error report about an application that's consuming too much battery. | public static final int | TYPE_RUNNING_SERVICEA report from a user to a developer about a running service that the
user doesn't think should be running. | public int | typeType of this report. Can be one of {@link #TYPE_NONE},
{@link #TYPE_CRASH}, {@link #TYPE_ANR}, {@link #TYPE_BATTERY},
or {@link #TYPE_RUNNING_SERVICE}. | public String | packageNamePackage name of the application. | public String | installerPackageNamePackage name of the application which installed the application this
report pertains to.
This identifies which market the application came from. | public String | processNameProcess name of the application. | public long | timeTime at which the error occurred. | public boolean | systemAppSet if the app is on the system image. | public CrashInfo | crashInfoIf this report is of type {@link #TYPE_CRASH}, contains an instance
of CrashInfo describing the crash; otherwise null. | public AnrInfo | anrInfoIf this report is of type {@link #TYPE_ANR}, contains an instance
of AnrInfo describing the ANR; otherwise null. | public BatteryInfo | batteryInfoIf this report is of type {@link #TYPE_BATTERY}, contains an instance
of BatteryInfo; otherwise null. | public RunningServiceInfo | runningServiceInfoIf this report is of type {@link #TYPE_RUNNING_SERVICE}, contains an instance
of RunningServiceInfo; otherwise null. | public static final Parcelable.Creator | CREATOR |
Constructors Summary |
---|
public ApplicationErrorReport()Create an uninitialized instance of {@link ApplicationErrorReport}.
| ApplicationErrorReport(android.os.Parcel in)Create an instance of {@link ApplicationErrorReport} initialized from
a parcel.
readFromParcel(in);
|
Methods Summary |
---|
public int | describeContents()
return 0;
| public void | dump(android.util.Printer pw, java.lang.String prefix)Dump the report to a Printer.
pw.println(prefix + "type: " + type);
pw.println(prefix + "packageName: " + packageName);
pw.println(prefix + "installerPackageName: " + installerPackageName);
pw.println(prefix + "processName: " + processName);
pw.println(prefix + "time: " + time);
pw.println(prefix + "systemApp: " + systemApp);
switch (type) {
case TYPE_CRASH:
crashInfo.dump(pw, prefix);
break;
case TYPE_ANR:
anrInfo.dump(pw, prefix);
break;
case TYPE_BATTERY:
batteryInfo.dump(pw, prefix);
break;
case TYPE_RUNNING_SERVICE:
runningServiceInfo.dump(pw, prefix);
break;
}
| public static android.content.ComponentName | getErrorReportReceiver(android.content.Context context, java.lang.String packageName, int appFlags)
// check if error reporting is enabled in secure settings
int enabled = Settings.Global.getInt(context.getContentResolver(),
Settings.Global.SEND_ACTION_APP_ERROR, 0);
if (enabled == 0) {
return null;
}
PackageManager pm = context.getPackageManager();
// look for receiver in the installer package
String candidate = null;
ComponentName result = null;
try {
candidate = pm.getInstallerPackageName(packageName);
} catch (IllegalArgumentException e) {
// the package could already removed
}
if (candidate != null) {
result = getErrorReportReceiver(pm, packageName, candidate);
if (result != null) {
return result;
}
}
// if the error app is on the system image, look for system apps
// error receiver
if ((appFlags&ApplicationInfo.FLAG_SYSTEM) != 0) {
candidate = SystemProperties.get(SYSTEM_APPS_ERROR_RECEIVER_PROPERTY);
result = getErrorReportReceiver(pm, packageName, candidate);
if (result != null) {
return result;
}
}
// if there is a default receiver, try that
candidate = SystemProperties.get(DEFAULT_ERROR_RECEIVER_PROPERTY);
return getErrorReportReceiver(pm, packageName, candidate);
| static android.content.ComponentName | getErrorReportReceiver(android.content.pm.PackageManager pm, java.lang.String errorPackage, java.lang.String receiverPackage)Return activity in receiverPackage that handles ACTION_APP_ERROR.
if (receiverPackage == null || receiverPackage.length() == 0) {
return null;
}
// break the loop if it's the error report receiver package that crashed
if (receiverPackage.equals(errorPackage)) {
return null;
}
Intent intent = new Intent(Intent.ACTION_APP_ERROR);
intent.setPackage(receiverPackage);
ResolveInfo info = pm.resolveActivity(intent, 0);
if (info == null || info.activityInfo == null) {
return null;
}
return new ComponentName(receiverPackage, info.activityInfo.name);
| public void | readFromParcel(android.os.Parcel in)
type = in.readInt();
packageName = in.readString();
installerPackageName = in.readString();
processName = in.readString();
time = in.readLong();
systemApp = in.readInt() == 1;
switch (type) {
case TYPE_CRASH:
crashInfo = new CrashInfo(in);
anrInfo = null;
batteryInfo = null;
runningServiceInfo = null;
break;
case TYPE_ANR:
anrInfo = new AnrInfo(in);
crashInfo = null;
batteryInfo = null;
runningServiceInfo = null;
break;
case TYPE_BATTERY:
batteryInfo = new BatteryInfo(in);
anrInfo = null;
crashInfo = null;
runningServiceInfo = null;
break;
case TYPE_RUNNING_SERVICE:
batteryInfo = null;
anrInfo = null;
crashInfo = null;
runningServiceInfo = new RunningServiceInfo(in);
break;
}
| public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeInt(type);
dest.writeString(packageName);
dest.writeString(installerPackageName);
dest.writeString(processName);
dest.writeLong(time);
dest.writeInt(systemApp ? 1 : 0);
switch (type) {
case TYPE_CRASH:
crashInfo.writeToParcel(dest, flags);
break;
case TYPE_ANR:
anrInfo.writeToParcel(dest, flags);
break;
case TYPE_BATTERY:
batteryInfo.writeToParcel(dest, flags);
break;
case TYPE_RUNNING_SERVICE:
runningServiceInfo.writeToParcel(dest, flags);
break;
}
|
|