//package org.acra.util;
import java.io.File;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Environment;
import android.os.StatFs;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
/**
* Responsible for providing base utilities used when constructing the report.
*
* @author William Ferguson
* @since 4.3.0
*/
public final class ReportUtils {
/**
* Returns a String representation of the content of a {@link android.view.Display} object.
*
* @param context Context for the application being reported.
* @return A String representation of the content of the default Display of the Window Service.
*/
public static String getDisplayDetails(Context context) {
try {
final WindowManager windowManager = (WindowManager) context.getSystemService(android.content.Context.WINDOW_SERVICE);
final Display display = windowManager.getDefaultDisplay();
final DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
final StringBuilder result = new StringBuilder();
result.append("width="). append(display.getWidth()).append('\n');
result.append("height="). append(display.getHeight()).append('\n');
result.append("pixelFormat="). append(display.getPixelFormat()).append('\n');
result.append("refreshRate="). append(display.getRefreshRate()).append("fps").append('\n');
result.append("metrics.density=x"). append(metrics.density).append('\n');
result.append("metrics.scaledDensity=x"). append(metrics.scaledDensity).append('\n');
result.append("metrics.widthPixels="). append(metrics.widthPixels).append('\n');
result.append("metrics.heightPixels="). append(metrics.heightPixels).append('\n');
result.append("metrics.xdpi="). append(metrics.xdpi).append('\n');
result.append("metrics.ydpi="). append(metrics.ydpi);
return result.toString();
} catch (RuntimeException e) {
// Log.w(ACRA.LOG_TAG, "Couldn't retrieve DisplayDetails for : " + context.getPackageName(), e);
return "Couldn't retrieve Display Details";
}
}
}