当前位置: 首页 > 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.lryc.cn/news/595548.html

相关文章:

  • LinkedList与链表(单向)(Java实现)
  • 跨端分栏布局:从手机到Pad的优雅切换
  • 遗像照片尺寸要求及手机制作打印方法
  • DIDCTF-2021第三届长安杯(检材一)
  • LeetCode 每日一题 2025/7/14-2025/7/20
  • Android Studio 的 Gradle 究竟是什么?
  • 力扣刷题 -- 100.相同的树
  • 4.Java创建对象有几种方式?
  • repmgr+pgbouncer实现对业务透明的高可用切换
  • ANSYS 2025 R1软件下载及安装教程|附安装文件
  • 【实战】Dify从0到100进阶--文档解读(10)参数提取HTTP节点
  • 2025年一区SCI-回旋镖气动椭圆优化算法Boomerang Aerodynamic Ellipse-附Matlab免费代码
  • IFN影视官网入口 - 4K影视在线看网站|网页|打不开|下载
  • 【智能协同云图库】智能协同云图库第二期:基于腾讯云 COS 对象存储—开发图片各功能模块
  • next.js刷新页面时二级菜单展开状态判断
  • 234、回文链表
  • lesson20:Python函数的标注
  • CMake与catkin_make的find_package()命令使用说明
  • 基于Vue与CloudBase AI Toolkit的色觉识别Web应用开发报告:VibeCoding新范式实践
  • 14.7 Alpaca格式深度解析:3倍指令准确率提升的LLM微调秘诀
  • 工业仪表识别(一)环境安装
  • 数据结构-哈希表(一)哈希函数、哈希表介绍、优缺点
  • 人工智能之数学基础:事件间的关系
  • Js进阶案例合集
  • doker centos7安装1
  • 大模型中的Actor-Critic机制
  • 直播专用域名租用全解析:开启直播新境界
  • 计算机史前时代:从原始计数到机械曙光
  • 什么是GNN?——聚合、更新与循环
  • 计算机发展史:集成电路时代的微缩革命