RK3399 Android7.1 修改壁纸

1.自定义壁纸


默认壁纸是default_wallpaper,在/frameworks/base/core/res/res,找到drawable-sw720dp-nodpi 、drawable-sw600dp-nodpi、drawable-nodpi的地方中有default_wallpaper.png,然后把自定义的壁纸(custom_wallpaper.png)也拷贝到相应的地方。

2.修改默认壁纸


加载壁纸的类frameworks/base/core/java/android/app/WallpaperManager.java ,custom_wallpaper是自定义壁纸的图片名字。

 

    /**
     * Open stream representing the default static image wallpaper.
     *
     * If the device defines no default wallpaper of the requested kind,
     * {@code null} is returned.
     *
     * @hide
     */
    public static InputStream openDefaultWallpaper(Context context, @SetWallpaperFlags int which) {
        final String whichProp;
        final int defaultResId;
        if (which == FLAG_LOCK) {
            /* Factory-default lock wallpapers are not yet supported
            whichProp = PROP_LOCK_WALLPAPER;
            defaultResId = com.android.internal.R.drawable.default_lock_wallpaper;
            */
            return null;
        } else {
            whichProp = PROP_WALLPAPER;
              //默认墙纸
           // defaultResId = com.android.internal.R.drawable.default_wallpaper;
            defaultResId = com.android.internal.R.drawable.custom_wallpaper;

        }
        final String path = SystemProperties.get(whichProp);
        if (!TextUtils.isEmpty(path)) {
            final File file = new File(path);
            if (file.exists()) {
                try {
                    return new FileInputStream(file);
                } catch (IOException e) {
                    // Ignored, fall back to platform default below
                }
            }
        }
        try {
            return context.getResources().openRawResource(defaultResId);
        } catch (NotFoundException e) {
            // no default defined for this device; this is not a failure
        }
        return null;

3.声明资源


在frameworks中添加资源不是直接把图片拷贝过去就可以的,还需要添加的新资源声明。frameworks/base/core/res/res/values/symbols.xml中添加新添加资源的字段。

 



 

你可能感兴趣的:(android,framework,修改壁纸,RK3399)