当前位置: 首页 > news >正文

Android MTK平台预置多张静态壁纸

执行 adb shell pm list package -f wallpaper  命令,查看壁纸应用路径:

/product/app/MtkWallpaperPicker/MtkWallpaperPicker.apk=com.android.wallpaperpicker

结果中带 Mtk 就可确定MTK有对应用进行重构。其源码路径在

vendor/mediatek/proprietary/packages/apps/WallpaperPicker

查看 WallpaperPickerActivity.java 

这里加载了多种不同来源的壁纸资源。

  protected void init() {setContentView(R.layout.wallpaper_picker);mCropView = (CropView) findViewById(R.id.cropView);mCropView.setVisibility(View.INVISIBLE);mProgressView = findViewById(R.id.loading);mWallpaperScrollContainer = (HorizontalScrollView) findViewById(R.id.wallpaper_scroll_container);mWallpaperStrip = findViewById(R.id.wallpaper_strip);mCropView.setTouchCallback(new ToggleOnTapCallback(mWallpaperStrip));mWallpaperParallaxOffset = getIntent().getFloatExtra(WallpaperUtils.EXTRA_WALLPAPER_OFFSET, 0);mWallpapersView = (LinearLayout) findViewById(R.id.wallpaper_list);// Populate the saved wallpapersmSavedImages = new SavedWallpaperImages(this);populateWallpapers(mWallpapersView, mSavedImages.loadThumbnailsAndImageIdList(), true);// Populate the built-in wallpapers.  这里是加载预置壁纸的地方。ArrayList<WallpaperTileInfo> wallpapers = findBundledWallpapers();populateWallpapers(mWallpapersView, wallpapers, false);// Load live wallpapers asynchronouslynew LiveWallpaperInfo.LoaderTask(this) {@Overrideprotected void onPostExecute(List<LiveWallpaperInfo> result) {populateWallpapers((LinearLayout) findViewById(R.id.live_wallpaper_list),result, false);initializeScrollForRtl();updateTileIndices();}}.execute();// Populate the third-party wallpaper pickerspopulateWallpapers((LinearLayout) findViewById(R.id.third_party_wallpaper_list),ThirdPartyWallpaperInfo.getAll(this), false /* addLongPressHandler */);// Add a tile for the GalleryLinearLayout masterWallpaperList = (LinearLayout) findViewById(R.id.master_wallpaper_list);masterWallpaperList.addView(createTileView(masterWallpaperList, new PickImageInfo(), false), 0);// Select the first item; wait for a layout pass so that we initialize the dimensions of// cropView or the defaultWallpaperView firstmCropView.addOnLayoutChangeListener(new OnLayoutChangeListener() {@Overridepublic void onLayoutChange(View v, int left, int top, int right, int bottom,int oldLeft, int oldTop, int oldRight, int oldBottom) {if ((right - left) > 0 && (bottom - top) > 0) {if (mSelectedIndex >= 0 && mSelectedIndex < mWallpapersView.getChildCount()) {onClick(mWallpapersView.getChildAt(mSelectedIndex));setSystemWallpaperVisiblity(false);}v.removeOnLayoutChangeListener(this);}}});

    public ArrayList<WallpaperTileInfo> findBundledWallpapers() {final ArrayList<WallpaperTileInfo> bundled = new ArrayList<WallpaperTileInfo>(24);//这里是根据xml中的配置加载资源,我们改这里。Pair<ApplicationInfo, Integer> r = getWallpaperArrayResourceId();if (r != null) {try {Resources wallpaperRes = getPackageManager().getResourcesForApplication(r.first);addWallpapers(bundled, wallpaperRes, r.first.packageName, r.second);} catch (PackageManager.NameNotFoundException e) {}}// Add an entry for the default wallpaper (stored in system resources)
//这里是默认的那张WallpaperTileInfo defaultWallpaperInfo = DefaultWallpaperInfo.get(this);if (defaultWallpaperInfo != null) {bundled.add(0, defaultWallpaperInfo);}return bundled;}

参考:android WallpaperPicker7.0源码分析_com.android.wallpaperpicker-CSDN博客

  public Pair<ApplicationInfo, Integer> getWallpaperArrayResourceId() {return new Pair<>(getApplicationInfo(), R.array.wallpapers);}

查询xml中wallpapers 配置。

  <string-array name="wallpapers" translatable="false">

<item>wp1</item>

        </string-array>

可以在此处添加多张图片

把图片放到 drawable 下,这里要注意需要同时配置*_small.jpg图片;

如 wp1.jpg, wp1_small.jpg.

编译 MtkWallpaperPicker 模块,然后push到机器中,杀死wallpaper进程即可。


 

http://www.dtcms.com/a/290177.html

相关文章:

  • Freemarker生成Word文档下载到浏览器(下载word)
  • 上海GEO优化公司找哪家怎么做
  • uniapp底部导航栏凸起
  • windows电脑给iOS手机安装ipa包的方法
  • Kubernetes Pod调度基础
  • Leetcode力扣解题记录--第238题(前/后缀积)
  • 【Git#6】多人协作 企业级开发模型
  • 3D可视化模型轻量化陷阱:STL转GLTF的精度损失与压缩比平衡策略
  • 【系统全面】Linux内核原理——基础知识介绍
  • H3C路由器模拟PPPOE拨号
  • MTSC2025参会感悟:Multi-Agent RAG 应用质量保障建设
  • Java IO流体系详解:字节流、字符流与NIO/BIO对比及文件拷贝实践
  • postgresql安装教程-个人笔记
  • 股票分红派息及其数据获取(使用Python)
  • selenium爬取图书信息
  • 关于JVM
  • 低速信号设计之 RGMII 篇
  • Rk3568驱动开发_非阻塞IO_16
  • 有关Mysql数据库的总结
  • Pytest 输出捕获详解:掌握如何查看和控制打印信息
  • Nacos 探活机制深度解析:临时 / 永久实例差异及与 Sentinel 的熔断协作
  • C++11之右值引用与移动语义(提高效率)重要
  • 「日拱一码」033 机器学习——严格划分
  • 【VASP】VASP 机器学习力场(MLFF)实战
  • 机器学习对词法分析、句法分析、浅层语义分析的积极影响
  • Taro 本地存储 API 详解与实用指南
  • 京东疯狂投资具身智能:众擎机器人+千寻智能+逐际动力 | AI早报
  • 从“被动照料”到“主动预防”:智慧养老定义的养老4.0时代
  • 迁移科技3D视觉系统:赋能机器人上下料,开启智能制造高效新纪元
  • Nacos中feign.FeignException$BadGateway: [502 Bad Gateway]