執行?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進程即可。
?