Search in sources :

Example 6 with ProcessErrorStateInfo

use of android.app.ActivityManager.ProcessErrorStateInfo in project android_frameworks_base by ResurrectionRemix.

the class ProcessErrorsTest method reportListContents.

/**
     * This helper function will dump the actual error reports.
     * 
     * @param errList The error report containing one or more error records.
     * @return Returns a string containing all of the errors.
     */
private static String reportListContents(Collection<ProcessErrorStateInfo> errList) {
    if (errList == null)
        return null;
    StringBuilder builder = new StringBuilder();
    Iterator<ProcessErrorStateInfo> iter = errList.iterator();
    while (iter.hasNext()) {
        ProcessErrorStateInfo entry = iter.next();
        String condition;
        switch(entry.condition) {
            case ActivityManager.ProcessErrorStateInfo.CRASHED:
                condition = "a CRASH";
                break;
            case ActivityManager.ProcessErrorStateInfo.NOT_RESPONDING:
                condition = "an ANR";
                break;
            default:
                condition = "an unknown error";
                break;
        }
        builder.append(String.format("Process %s encountered %s (%s)", entry.processName, condition, entry.shortMsg));
        if (entry.condition == ActivityManager.ProcessErrorStateInfo.CRASHED) {
            builder.append(String.format(" with stack trace:\n%s\n", entry.stackTrace));
        }
        builder.append("\n");
    }
    return builder.toString();
}
Also used : ProcessErrorStateInfo(android.app.ActivityManager.ProcessErrorStateInfo)

Example 7 with ProcessErrorStateInfo

use of android.app.ActivityManager.ProcessErrorStateInfo in project android_frameworks_base by DirtyUnicorns.

the class AppCompatibility method launchActivity.

/**
     * Launches and activity and queries for errors.
     *
     * @param packageName {@link String} the package name of the application to
     *            launch.
     * @return {@link Collection} of {@link ProcessErrorStateInfo} detected
     *         during the app launch.
     */
private ProcessErrorStateInfo launchActivity(String packageName, Intent intent) {
    Log.d(TAG, String.format("launching package \"%s\" with intent: %s", packageName, intent.toString()));
    String processName = getProcessName(packageName);
    // Launch Activity
    mContext.startActivity(intent);
    try {
        Thread.sleep(mAppLaunchTimeout);
    } catch (InterruptedException e) {
    // ignore
    }
    // See if there are any errors. We wait until down here to give ANRs as much time as
    // possible to occur.
    final Collection<ProcessErrorStateInfo> postErr = mActivityManager.getProcessesInErrorState();
    if (postErr == null) {
        return null;
    }
    for (ProcessErrorStateInfo error : postErr) {
        if (error.processName.equals(processName)) {
            return error;
        }
    }
    return null;
}
Also used : ProcessErrorStateInfo(android.app.ActivityManager.ProcessErrorStateInfo)

Example 8 with ProcessErrorStateInfo

use of android.app.ActivityManager.ProcessErrorStateInfo in project android_frameworks_base by DirtyUnicorns.

the class AppLaunch method reportError.

private void reportError(String appName, String processName) {
    ActivityManager am = (ActivityManager) getInstrumentation().getContext().getSystemService(Context.ACTIVITY_SERVICE);
    List<ProcessErrorStateInfo> crashes = am.getProcessesInErrorState();
    if (crashes != null) {
        for (ProcessErrorStateInfo crash : crashes) {
            if (!crash.processName.equals(processName))
                continue;
            Log.w(TAG, appName + " crashed: " + crash.shortMsg);
            mResult.putString(mNameToResultKey.get(appName), crash.shortMsg);
            return;
        }
    }
    mResult.putString(mNameToResultKey.get(appName), "Crashed for unknown reason");
    Log.w(TAG, appName + " not found in process list, most likely it is crashed");
}
Also used : ProcessErrorStateInfo(android.app.ActivityManager.ProcessErrorStateInfo) ActivityManager(android.app.ActivityManager) IActivityManager(android.app.IActivityManager)

Example 9 with ProcessErrorStateInfo

use of android.app.ActivityManager.ProcessErrorStateInfo in project android_frameworks_base by DirtyUnicorns.

the class MemoryUsageTest method reportError.

private void reportError(String appName, String processName, Bundle results) {
    ActivityManager am = (ActivityManager) getInstrumentation().getContext().getSystemService(Context.ACTIVITY_SERVICE);
    List<ProcessErrorStateInfo> crashes = am.getProcessesInErrorState();
    if (crashes != null) {
        for (ProcessErrorStateInfo crash : crashes) {
            if (!crash.processName.equals(processName))
                continue;
            Log.w(TAG, appName + " crashed: " + crash.shortMsg);
            results.putString(mNameToResultKey.get(appName), crash.shortMsg);
            return;
        }
    }
    results.putString(mNameToResultKey.get(appName), "Crashed for unknown reason");
    Log.w(TAG, appName + " not found in process list, most likely it is crashed");
}
Also used : ProcessErrorStateInfo(android.app.ActivityManager.ProcessErrorStateInfo) ActivityManager(android.app.ActivityManager) IActivityManager(android.app.IActivityManager)

Example 10 with ProcessErrorStateInfo

use of android.app.ActivityManager.ProcessErrorStateInfo in project android_frameworks_base by DirtyUnicorns.

the class ProcessErrorsTest method reportListContents.

/**
     * This helper function will dump the actual error reports.
     * 
     * @param errList The error report containing one or more error records.
     * @return Returns a string containing all of the errors.
     */
private static String reportListContents(Collection<ProcessErrorStateInfo> errList) {
    if (errList == null)
        return null;
    StringBuilder builder = new StringBuilder();
    Iterator<ProcessErrorStateInfo> iter = errList.iterator();
    while (iter.hasNext()) {
        ProcessErrorStateInfo entry = iter.next();
        String condition;
        switch(entry.condition) {
            case ActivityManager.ProcessErrorStateInfo.CRASHED:
                condition = "a CRASH";
                break;
            case ActivityManager.ProcessErrorStateInfo.NOT_RESPONDING:
                condition = "an ANR";
                break;
            default:
                condition = "an unknown error";
                break;
        }
        builder.append(String.format("Process %s encountered %s (%s)", entry.processName, condition, entry.shortMsg));
        if (entry.condition == ActivityManager.ProcessErrorStateInfo.CRASHED) {
            builder.append(String.format(" with stack trace:\n%s\n", entry.stackTrace));
        }
        builder.append("\n");
    }
    return builder.toString();
}
Also used : ProcessErrorStateInfo(android.app.ActivityManager.ProcessErrorStateInfo)

Aggregations

ProcessErrorStateInfo (android.app.ActivityManager.ProcessErrorStateInfo)25 ActivityManager (android.app.ActivityManager)11 IActivityManager (android.app.IActivityManager)10 Intent (android.content.Intent)6 Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 ContentValues (android.content.ContentValues)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Cursor (android.database.Cursor)1 SQLException (android.database.SQLException)1