Android 12系统开机后第一次默认壁纸被拉伸

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);
       }
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
如果在 Android 12 上使用内置壁纸时出现拉伸的问题,您可以尝试以下解决方法: 1. 调整壁纸设置:在设备的壁纸设置中,尝试调整壁纸的显示方式。有些设备提供了不同的选项,例如"填充"、"适应"或"居中",您可以尝试选择适合您的壁纸的选项。 2. 自定义裁剪壁纸:如果设备的壁纸设置没有合适的选项,您可以尝试使用第三方壁纸应用或图片编辑应用来自定义裁剪壁纸。将壁纸调整为与您设备屏幕分辨率匹配的尺寸,以避免拉伸。 3. 使用高质量壁纸:确保您使用的是高质量的壁纸图像。低分辨率或拉伸的图像可能会导致拉伸效果更加明显。尽量选择与您设备屏幕分辨率匹配或更高的壁纸图像。 4. 更新系统或应用程序:检查是否有可用的系统更新或应用程序更新。有时,厂商会提供修复壁纸显示问题的更新。 5. 反馈给开发者:如果以上方法都无法解决问题,您可以向设备制造商或 Android 开发者社区反馈该问题。他们可能能够提供进一步的帮助或修复此问题的未来更新。 请注意,不同的设备和 Android 版本可能会有不同的壁纸显示设置和选项。因此,上述解决方法可能对某些设备有效,但在其他设备上可能不适用。建议根据您的具体设备和 Android 版本进行适当的调整和尝试。 希望这些建议对您有所帮助!如果您还有其他问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

android framework

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值