diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
old mode 100644
new mode 100755
index 50d862dee2…542d447e85
— a/frameworks/base/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -37,7 +37,7 @@ import android.view.WindowManager;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
+import android.view.WindowManager;
/**
- Default built-in wallpaper that simply shows a static image.
*/
@@ -45,7 +45,7 @@ import java.io.PrintWriter;
public class ImageWallpaper extends WallpaperService {
private static final String TAG = “ImageWallpaper”;
private static final String GL_LOG_TAG = “ImageWallpaperGL”;
- private static final boolean DEBUG = false;
- private static final boolean DEBUG = true;
private static final String PROPERTY_KERNEL_QEMU = “ro.kernel.qemu”;
private static final long DELAY_FORGET_WALLPAPER = 5000;
@@ -162,10 +162,39 @@ public class ImageWallpaper extends WallpaperService {
// Used a fixed size surface, because we are special. We can do
// this because we know the current design of window animations doesn’t
// cause this to break.
-
WindowManager mWindowManager = (WindowManager)getSystemService(WindowManager.class); -
int wW = mWindowManager.getDefaultDisplay().getWidth(); -
int wH = mWindowManager.getDefaultDisplay().getHeight(); -
int width = surfaceWidth; -
int height = surfaceHeight; -
int inSampleSize = 1; -
if (width > wW && height > wH){ -
int widthRatio = Math.round((float) width / (float) wW); -
int heightRatio = Math.round((float) height / (float) wH); -
inSampleSize = Math.max(widthRatio, heightRatio); -
}else{ -
int widthRatio = Math.round((float) wW / (float) width); -
int heightRatio = Math.round((float) wH / (float) height); -
inSampleSize = Math.min(widthRatio, heightRatio); -
} -
if (inSampleSize > 1.5){ -
Log.d(TAG, "setFixedSize wW."+wW +" wH:"+wH); -
surfaceHolder.setFixedSize(wW, wH); -
mLastRequestedWidth = wW; -
mLastRequestedHeight = wH; -
}else if(inSampleSize < 0.5){ -
Log.d(TAG, "setFixedSize wW."+wW +" wH:"+wH); -
surfaceHolder.setFixedSize(wW, wH); -
mLastRequestedWidth = wW; -
mLastRequestedHeight = wH; -
}else{ -
Log.d(TAG, "setFixedSize surfaceWidth."+surfaceWidth); -
Log.d(TAG, "setFixedSize surfaceHeight."+surfaceHeight); surfaceHolder.setFixedSize(surfaceWidth, surfaceHeight); mLastRequestedWidth = surfaceWidth; mLastRequestedHeight = surfaceHeight;
-
} return hasWallpaper; }
@@ -425,6 +454,10 @@ public class ImageWallpaper extends WallpaperService {
if (DEBUG) {
Log.d(TAG, "Wallpaper loaded: " + mBackground);
-
if(mBackground !=null){ -
Log.d(TAG, "Wallpaper getWidth: " + mBackground.getWidth()); -
Log.d(TAG, "Wallpaper getHeight: " + mBackground.getHeight()); -
} } updateSurfaceSize(getSurfaceHolder(), getDefaultDisplayInfo(), false /* forDraw */);
diff --git a/frameworks/base/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/frameworks/base/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
m
old mode 100644
new mode 100755
index 547ab0ed44…55c4b5dd54
— a/frameworks/base/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -667,7 +667,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
// scale if the crop height winds up not matching the recommended metrics
needScale = (wallpaper.height != cropHint.height());
-
needScale = false; if (DEBUG) { Slog.v(TAG, "crop: w=" + cropHint.width() + " h=" + cropHint.height()); Slog.v(TAG, "dims: w=" + wallpaper.width + " h=" + wallpaper.height);
这篇博客讨论了Android系统中设置图片为壁纸时出现的拉伸现象,并着重分析了`ImageWallpaper.java`文件的代码变更,通过比较旧版与新版的差异,探讨了解决壁纸拉伸的可能方法。

2056

被折叠的 条评论
为什么被折叠?



