作者: | 来源:互联网 | 2023-09-23 15:17
从Android N开始,原生系统增加了锁屏壁纸开关:
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
/** If true, the lockscreen will show a distinct wallpaper */private static final boolean ENABLE_LOCKSCREEN_WALLPAPER = true;
要设置出厂默认锁屏壁纸,修改如下代码即可实现:
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
public Bitmap getBitmap() {if (mCached) {return mCache;}if (!mWallpaperManager.isWallpaperSupported()) {mCached = true;mCache = null;return null;}LoaderResult result = loadBitmap(mCurrentUserId, mSelectedUser);if (result.success) {mCached = true;mUpdateMonitor.setHasLockscreenWallpaper(result.bitmap != null);mCache = result.bitmap;}if (mCache == null) {try {mWallpaperManager.setStream(mContext.getResources().openRawResource(com.android.internal.R.drawable.default_lock_wallpaper),null,true,WallpaperManager.FLAG_LOCK);result = loadBitmap(mCurrentUserId, mSelectedUser);if (result.success) {mCached = true;mUpdateMonitor.setHasLockscreenWallpaper(result.bitmap != null);mCache = result.bitmap;}} catch (IOException e) {Log.e(TAG, "can not set default lockscreen wallpaper");}}return mCache;}
然后放入系统资源图片default_lock_wallpaper即可。