use of android.os.DeadSystemException in project android_frameworks_base by ResurrectionRemix.
the class Log method printlns.
/**
* Helper function for long messages. Uses the LineBreakBufferedWriter to break
* up long messages and stacktraces along newlines, but tries to write in large
* chunks. This is to avoid truncation.
* @hide
*/
public static int printlns(int bufID, int priority, String tag, String msg, Throwable tr) {
ImmediateLogWriter logWriter = new ImmediateLogWriter(bufID, priority, tag);
// Acceptable buffer size. Get the native buffer size, subtract two zero terminators,
// and the length of the tag.
// Note: we implicitly accept possible truncation for Modified-UTF8 differences. It
// is too expensive to compute that ahead of time.
int bufferSize = // Base.
NoPreloadHolder.LOGGER_ENTRY_MAX_PAYLOAD - // Two terminators.
2 - // Tag length.
(tag != null ? tag.length() : 0) - // Some slack.
32;
// At least assume you can print *some* characters (tag is not too large).
bufferSize = Math.max(bufferSize, 100);
LineBreakBufferedWriter lbbw = new LineBreakBufferedWriter(logWriter, bufferSize);
lbbw.println(msg);
if (tr != null) {
// This is to reduce the amount of log spew that apps do in the non-error
// condition of the network being unavailable.
Throwable t = tr;
while (t != null) {
if (t instanceof UnknownHostException) {
break;
}
if (t instanceof DeadSystemException) {
lbbw.println("DeadSystemException: The system died; " + "earlier logs will point to the root cause");
break;
}
t = t.getCause();
}
if (t == null) {
tr.printStackTrace(lbbw);
}
}
lbbw.flush();
return logWriter.getWritten();
}
use of android.os.DeadSystemException in project android_frameworks_base by ResurrectionRemix.
the class WallpaperManager method setResource.
/**
* Version of {@link #setResource(int)} that allows the caller to specify which
* of the supported wallpaper categories to set.
*
* @param resid The resource ID of the bitmap to be used as the wallpaper image
* @param which Flags indicating which wallpaper(s) to configure with the new imagery
*
* @see #FLAG_LOCK
* @see #FLAG_SYSTEM
*
* @return An integer ID assigned to the newly active wallpaper; or zero on failure.
*
* @throws IOException
*/
public int setResource(@RawRes int resid, @SetWallpaperFlags int which) throws IOException {
if (sGlobals.mService == null) {
Log.w(TAG, "WallpaperService not running");
throw new RuntimeException(new DeadSystemException());
}
final Bundle result = new Bundle();
final WallpaperSetCompletion completion = new WallpaperSetCompletion();
try {
Resources resources = mContext.getResources();
/* Set the wallpaper to the default values */
ParcelFileDescriptor fd = sGlobals.mService.setWallpaper("res:" + resources.getResourceName(resid), mContext.getOpPackageName(), null, false, result, which, completion, UserHandle.myUserId());
if (fd != null) {
FileOutputStream fos = null;
boolean ok = false;
try {
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
copyStreamToWallpaperFile(resources.openRawResource(resid), fos);
// The 'close()' is the trigger for any server-side image manipulation,
// so we must do that before waiting for completion.
fos.close();
completion.waitForCompletion();
} finally {
// Might be redundant but completion shouldn't wait unless the write
// succeeded; this is a fallback if it threw past the close+wait.
IoUtils.closeQuietly(fos);
}
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return result.getInt(EXTRA_NEW_WALLPAPER_ID, 0);
}
use of android.os.DeadSystemException in project android_frameworks_base by ResurrectionRemix.
the class WallpaperManager method hasResourceWallpaper.
/**
* Return whether any users are currently set to use the wallpaper
* with the given resource ID. That is, their wallpaper has been
* set through {@link #setResource(int)} with the same resource id.
*/
public boolean hasResourceWallpaper(@RawRes int resid) {
if (sGlobals.mService == null) {
Log.w(TAG, "WallpaperService not running");
throw new RuntimeException(new DeadSystemException());
}
try {
Resources resources = mContext.getResources();
String name = "res:" + resources.getResourceName(resid);
return sGlobals.mService.hasNamedWallpaper(name);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
use of android.os.DeadSystemException in project android_frameworks_base by DirtyUnicorns.
the class WallpaperManager method hasResourceWallpaper.
/**
* Return whether any users are currently set to use the wallpaper
* with the given resource ID. That is, their wallpaper has been
* set through {@link #setResource(int)} with the same resource id.
*/
public boolean hasResourceWallpaper(@RawRes int resid) {
if (sGlobals.mService == null) {
Log.w(TAG, "WallpaperService not running");
throw new RuntimeException(new DeadSystemException());
}
try {
Resources resources = mContext.getResources();
String name = "res:" + resources.getResourceName(resid);
return sGlobals.mService.hasNamedWallpaper(name);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
use of android.os.DeadSystemException in project android_frameworks_base by DirtyUnicorns.
the class WallpaperManager method suggestDesiredDimensions.
/**
* For use only by the current home application, to specify the size of
* wallpaper it would like to use. This allows such applications to have
* a virtual wallpaper that is larger than the physical screen, matching
* the size of their workspace.
*
* <p>Note developers, who don't seem to be reading this. This is
* for <em>home apps</em> to tell what size wallpaper they would like.
* Nobody else should be calling this! Certainly not other non-home
* apps that change the wallpaper. Those apps are supposed to
* <b>retrieve</b> the suggested size so they can construct a wallpaper
* that matches it.
*
* <p>This method requires the caller to hold the permission
* {@link android.Manifest.permission#SET_WALLPAPER_HINTS}.
*
* @param minimumWidth Desired minimum width
* @param minimumHeight Desired minimum height
*/
public void suggestDesiredDimensions(int minimumWidth, int minimumHeight) {
try {
/**
* The framework makes no attempt to limit the window size
* to the maximum texture size. Any window larger than this
* cannot be composited.
*
* Read maximum texture size from system property and scale down
* minimumWidth and minimumHeight accordingly.
*/
int maximumTextureSize;
try {
maximumTextureSize = SystemProperties.getInt("sys.max_texture_size", 0);
} catch (Exception e) {
maximumTextureSize = 0;
}
if (maximumTextureSize > 0) {
if ((minimumWidth > maximumTextureSize) || (minimumHeight > maximumTextureSize)) {
float aspect = (float) minimumHeight / (float) minimumWidth;
if (minimumWidth > minimumHeight) {
minimumWidth = maximumTextureSize;
minimumHeight = (int) ((minimumWidth * aspect) + 0.5);
} else {
minimumHeight = maximumTextureSize;
minimumWidth = (int) ((minimumHeight / aspect) + 0.5);
}
}
}
if (sGlobals.mService == null) {
Log.w(TAG, "WallpaperService not running");
throw new RuntimeException(new DeadSystemException());
} else {
sGlobals.mService.setDimensionHints(minimumWidth, minimumHeight, mContext.getOpPackageName());
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
Aggregations