最近编译Android 7.1,编译完后系统中设置的壁纸不能正常显示

修改位置:7.1SDK/packages/apps/WallpaperPicker/src/com/android/wallpaperpicker/WallpaperUtils.java

             // We need to ensure that there is enough extra space in the wallpaper             // for the intended parallax effects-            final int defaultWidth, defaultHeight;+            int defaultWidth, defaultHeight;             if (res.getConfiguration().smallestScreenWidthDp >= 720) {                 defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));                 defaultHeight = maxDim;@@ -145,6 +145,8 @@ public final class WallpaperUtils {                 defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim);                 defaultHeight = maxDim;             }+            defaultWidth = maxDim;+            defaultHeight = minDim;             sDefaultWallpaperSize = new Point(defaultWidth, defaultHeight);         }         return sDefaultWallpaperSize;

修改位置:7.1SDK/frameworks/base/core/java/android/app/WallpaperManager.java

@@ -55,6 +55,7 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.text.TextUtils; import android.util.Log;+import android.view.WindowManager; import android.view.WindowManagerGlobal; import libcore.io.IoUtils;@@ -310,7 +311,7 @@ public class WallpaperManager {                 mCachedWallpaper = null;                 mCachedWallpaperUserId = 0;                 try {-                    mCachedWallpaper = getCurrentWallpaperLocked(userId);+                    mCachedWallpaper = getCurrentWallpaperLocked(context, userId);                     mCachedWallpaperUserId = userId;                 } catch (OutOfMemoryError e) {                     Log.w(TAG, "No memory load current wallpaper", e);@@ -342,7 +343,7 @@ public class WallpaperManager {           }         }-        private Bitmap getCurrentWallpaperLocked(int userId) {+        private Bitmap getCurrentWallpaperLocked(Context context, int userId) {             if (mService == null) {                 Log.w(TAG, "WallpaperService not running");                 return null;@@ -354,7 +355,14 @@ public class WallpaperManager {                         params, userId);                 if (fd != null) {                     try {+                        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(fd.getFileDescriptor(), null, options);+                        options.inSampleSize = calculateInSampleSize(options, wW, wH);+                        options.inJustDecodeBounds = false;                         return BitmapFactory.decodeFileDescriptor(                                 fd.getFileDescriptor(), null, options);                     } catch (OutOfMemoryError e) {@@ -368,6 +376,18 @@ public class WallpaperManager {             }             return 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 getDefaultWallpaper(Context context, @SetWallpaperFlags int which) {             InputStream is = openDefaultWallpaper(context, which);

修改位置:7.1SDK/frameworks/base/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java

@@ -229,7 +229,7 @@ public class ImageWallpaper extends WallpaperService {                 surfaceHeight = Math.max(displayInfo.logicalHeight, mBackgroundHeight);             }-            if (FIXED_SIZED_SURFACE) {+            if (false) {                 // 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.
修改之后,系统默认设置的壁纸可以正常显示。剩下的问题还在探索中。



更多相关文章

  1. android 设置系统屏幕亮度
  2. android 查看系统分配程序内存限制
  3. CreateProcess error = 2,系统找不到指定的文件
  4. Android AudioManager控制系统声音的流程
  5. Android apk获取系统权限
  6. Android系统架构及特点

随机推荐

  1. Android实现ListView异步加载图片
  2. Java,Android Integer和byte的相互转换,Jav
  3. 用ndk-build 工具手动生成编译android原
  4. Android 自定义View(API解析+Demo)
  5. 图片中的毕加索【Picasso】
  6. Android 新手常见的10个误区(下)
  7. android 动态控制状态栏显示和隐藏的方法
  8. android视图继承关系
  9. Android通过PagerSnapHelper改造Recycler
  10. Android文件系统的结构及目录用途、操作