最近编译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 编译源码6.0 问题记录
  2. Android(安卓)添加永不休眠
  3. gradle编译带so的aar,并引入工程
  4. linux 下编译 vlc
  5. Android(安卓)Studio下项目编译出错could not find com.android.
  6. 导入android studio 项目错误:Error:(1, 0) Plugin with id 'com.
  7. 修改Android(安卓)framework定制重启功能
  8. android 5.0修改插电显示电池百分比,拔掉不显示问题
  9. Android(安卓)O添加Settings设置项的方法

随机推荐

  1. Mongodb 的ORM框架 Morphia 注解二 ——
  2. 实例讲解:.NET如何访问MySQL数据库
  3. MYSQL中update语句 与in 的bug
  4. MySQL入门第三天(下)——存储过程与存储引
  5. win10 64位安装绿色版mysql-5.7.16-winx6
  6. 从phpMyAdmin中找出MySQL数据库URL
  7. 急,mysql大数据量性能优化
  8. MYSQL查询语句:排名在第3名的成绩是多少?
  9. mysql通用二进制格式安装
  10. 【mysql】mysql中的锁机制