use of android.os.DeadSystemException in project android_frameworks_base by AOSPA.
the class WallpaperManager method setBitmap.
/**
* Like {@link #setBitmap(Bitmap, Rect, boolean, int)}, but allows to pass in an explicit user
* id. If the user id doesn't match the user id the process is running under, calling this
* requires permission {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL}.
* @hide
*/
public int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, @SetWallpaperFlags int which, int userId) throws IOException {
validateRect(visibleCropHint);
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 {
ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null, mContext.getOpPackageName(), visibleCropHint, allowBackup, result, which, completion, userId);
if (fd != null) {
FileOutputStream fos = null;
try {
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
fullImage.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.close();
completion.waitForCompletion();
} finally {
IoUtils.closeQuietly(fos);
}
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return result.getInt(EXTRA_NEW_WALLPAPER_ID, 0);
}
use of android.os.DeadSystemException in project platform_frameworks_base by android.
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();
}
}
use of android.os.DeadSystemException in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class WallpaperManager method setStream.
/**
* Version of {@link #setStream(InputStream, Rect, boolean)} that allows the caller
* to specify which of the supported wallpaper categories to set.
*
* @param bitmapData A stream containing the raw data to install as a wallpaper. This
* data can be in any format handled by {@link BitmapRegionDecoder}.
* @param visibleCropHint The rectangular subregion of the streamed image that should be
* displayed as wallpaper. Passing {@code null} for this parameter means that
* the full image should be displayed if possible given the image's and device's
* aspect ratios, etc.
* @param allowBackup {@code true} if the OS is permitted to back up this wallpaper
* image for restore to a future device; {@code false} otherwise.
* @param which Flags indicating which wallpaper(s) to configure with the new imagery.
* @return An integer ID assigned to the newly active wallpaper; or zero on failure.
*
* @see #getWallpaperId(int)
* @see #FLAG_LOCK
* @see #FLAG_SYSTEM
*
* @throws IOException
*/
public int setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, @SetWallpaperFlags int which) throws IOException {
validateRect(visibleCropHint);
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 {
ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null, mContext.getOpPackageName(), visibleCropHint, allowBackup, result, which, completion, UserHandle.myUserId());
if (fd != null) {
FileOutputStream fos = null;
try {
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
copyStreamToWallpaperFile(bitmapData, fos);
fos.close();
completion.waitForCompletion();
} finally {
IoUtils.closeQuietly(fos);
}
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return result.getInt(EXTRA_NEW_WALLPAPER_ID, 0);
}
use of android.os.DeadSystemException in project platform_frameworks_base by android.
the class WallpaperManager method setBitmap.
/**
* Like {@link #setBitmap(Bitmap, Rect, boolean, int)}, but allows to pass in an explicit user
* id. If the user id doesn't match the user id the process is running under, calling this
* requires permission {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL}.
* @hide
*/
public int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, @SetWallpaperFlags int which, int userId) throws IOException {
validateRect(visibleCropHint);
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 {
ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null, mContext.getOpPackageName(), visibleCropHint, allowBackup, result, which, completion, userId);
if (fd != null) {
FileOutputStream fos = null;
try {
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
fullImage.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.close();
completion.waitForCompletion();
} finally {
IoUtils.closeQuietly(fos);
}
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return result.getInt(EXTRA_NEW_WALLPAPER_ID, 0);
}
Aggregations