diff --git a/frameworks/base/core/java/android/app/WallpaperManager.java b/frameworks/base/core/java/android/app/WallpaperManager.java
old mode 100644
new mode 100755
index fca4c698c4…0e508eeec8
— a/frameworks/base/core/java/android/app/WallpaperManager.java
+++ b/frameworks/base/core/java/android/app/WallpaperManager.java
@@ -94,7 +94,7 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import android.view.WindowManager;
/**
- Provides access to the system wallpaper. With WallpaperManager, you can
- get the current wallpaper, get the desired dimensions for the wallpaper, set
@@ -560,6 +560,9 @@ public class WallpaperManager {
mCachedWallpaper = getCurrentWallpaperLocked(
context, userId, hardware, cmProxy);
mCachedWallpaperUserId = userId;
-
if(mCachedWallpaper !=null){
-
Log.v(TAG, "mCachedWallpaper getWidth:"+mCachedWallpaper.getWidth() +" mCachedWallpaper getHeight:"+mCachedWallpaper.getHeight() );
-
} } catch (OutOfMemoryError e) { Log.w(TAG, "Out of memory loading the current wallpaper: " + e); } catch (SecurityException e) {
@@ -582,6 +585,9 @@ public class WallpaperManager {
synchronized (this) {
mDefaultWallpaper = defaultWallpaper;
}
-
if(defaultWallpaper !=null){
-
Log.v(TAG, "defaultWallpaper getWidth:"+defaultWallpaper.getWidth() +" defaultWallpaper getHeight:"+defaultWallpaper.getHeight() );
-
} } return defaultWallpaper; }
@@ -609,9 +615,33 @@ public class WallpaperManager {
// Let’s peek user wallpaper first.
if (pfd != null) {
BitmapFactory.Options options = new BitmapFactory.Options();
-
options.inJustDecodeBounds = true;
-
WindowManager mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
-
int wW = mWindowManager.getDefaultDisplay().getWidth();
-
int wH = mWindowManager.getDefaultDisplay().getHeight();
-
/*
-
options.inJustDecodeBounds = true; BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor(), null, options);
-
options.inSampleSize = calculateInSampleSize(options, wW, wH);
-
options.inJustDecodeBounds = false;
-
BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor(), null, options);
-
*/
-
options.inJustDecodeBounds = true;
-
BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor(), null, options);
-
options.inSampleSize = calculateInSampleSize(options, wW, wH);
-
options.inJustDecodeBounds = false;
-
BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor(), null, options);
-
Log.w(TAG, "options.outWidth:"+ options.outWidth +" options.outHeight:"+options.outHeight); dimensions = new Rect(0, 0, options.outWidth, options.outHeight);
-
boolean aBoolean2 = android.os.SystemProperties.getBoolean("persist.wallpaper.one", false);
-
if (aBoolean2) {
-
android.os.TransactionTooLargeException transactionTooLargeException = new android.os.TransactionTooLargeException();
-
transactionTooLargeException.fillInStackTrace();
-
transactionTooLargeException.printStackTrace();
-
transactionTooLargeException.getCause().printStackTrace();
-
} } } catch (RemoteException ex) { Log.w(TAG, "peek wallpaper dimensions failed", ex);
@@ -649,6 +679,18 @@ public class WallpaperManager {
mDefaultWallpaper = null;
}
}
+
-
private int calculateInSampleSize(BitmapFactory.Options options,int reqWidth, int reqHeight){
-
int width = options.outWidth;
-
int height = options.outHeight;
-
int inSampleSize = 1;
-
if (width > reqWidth && height > reqHeight) {
-
int widthRatio = Math.round((float) width / (float) reqWidth);
-
int heightRatio = Math.round((float) width / (float) reqWidth);
-
inSampleSize = Math.max(widthRatio, heightRatio);
-
}
-
return inSampleSize;
-
} private Bitmap getCurrentWallpaperLocked(Context context, int userId, boolean hardware, ColorManagementProxy cmProxy) {
@@ -666,6 +708,20 @@ public class WallpaperManager {
if (pfd != null) {
try (BufferedInputStream bis = new BufferedInputStream(
new ParcelFileDescriptor.AutoCloseInputStream(pfd))) {
-
/*
-
WindowManager mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
-
int wW = mWindowManager.getDefaultDisplay().getWidth();
-
int wH = mWindowManager.getDefaultDisplay().getHeight();
-
BitmapFactory.Options options = new BitmapFactory.Options();
-
options.inJustDecodeBounds = true;
-
// BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor(), null, options);
-
BitmapFactory.decodeStream(bis, null, options);
-
options.inSampleSize = calculateInSampleSize(options, wW, wH);
-
options.inJustDecodeBounds = false;
-
return BitmapFactory.decodeStream(
-
bis, null, options);
-
*/ final ByteArrayOutputStream baos = new ByteArrayOutputStream(); int data; while ((data = bis.read()) != -1) {
@@ -680,6 +736,7 @@ public class WallpaperManager {
cmProxy.doColorManagement(decoder, info);
}
}));
+
} catch (OutOfMemoryError | IOException e) {
Log.w(TAG, “Can’t decode file”, e);
}
@@ -695,6 +752,16 @@ public class WallpaperManager {
if (is != null) {
try {
BitmapFactory.Options options = new BitmapFactory.Options();
-
/*
-
WindowManager mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
-
int wW = mWindowManager.getDefaultDisplay().getWidth();
-
int wH = mWindowManager.getDefaultDisplay().getHeight();
-
options.inJustDecodeBounds = true;
-
// BitmapFactory.decodeFileDescriptor(fd.getFileDescriptor(), null, options);
-
BitmapFactory.decodeStream(is, null, options);
-
options.inSampleSize = calculateInSampleSize(options, wW, wH);
-
options.inJustDecodeBounds = false;
-
*/ return BitmapFactory.decodeStream(is, null, options); } catch (OutOfMemoryError e) { Log.w(TAG, "Can't decode stream", e);
@@ -1869,6 +1936,7 @@ public class WallpaperManager {
int maximumTextureSize;
try {
maximumTextureSize = SystemProperties.getInt(“sys.max_texture_size”, 0);
-
Log.w(TAG, "maximumTextureSize:"+maximumTextureSize); } catch (Exception e) { maximumTextureSize = 0; }
@@ -2218,6 +2286,7 @@ public class WallpaperManager {
defaultResId = com.android.internal.R.drawable.default_wallpaper;
}
final String path = SystemProperties.get(whichProp);
-
Log.w(TAG, "wallpaper path:"+path); final InputStream wallpaperInputStream = getWallpaperInputStream(path); if (wallpaperInputStream != null) { return wallpaperInputStream;
@@ -2250,6 +2319,7 @@ public class WallpaperManager {
}
private static String getCmfWallpaperPath() {
-
Log.w(TAG, "hardware.color:"+VALUE_CMF_COLOR); return Environment.getProductDirectory() + WALLPAPER_CMF_PATH + "default_wallpaper_" + VALUE_CMF_COLOR;
}
@@ -2264,6 +2334,7 @@ public class WallpaperManager {
ComponentName cn = null;String flat = SystemProperties.get(PROP_WALLPAPER_COMPONENT);
-
Log.w(TAG, "wallpaper_component flat:"+flat); if (!TextUtils.isEmpty(flat)) { cn = ComponentName.unflattenFromString(flat); }