前言
欢迎大家我分享和推荐好用的代码段~~
声明
欢迎转载,但请保留文章原始出处:
CSDN:http://www.csdn.net
雨季o莫忧离:http://blog.csdn.net/luckkof
正文
在config.xml文件里修改default_wallpaper_component这个属性,使得第一次开机默认为其他壁纸应用。
开机后进入设置-》应用程序-》全部-》找到第一次开机默认墙纸的apk-》点击进入-》选择停用,会导致死机。怎样修改代码,使得在这种场景下,手机不死机,并让壁纸恢复到ImageWallpaper。
请在WallpaperManagerService.java中的bindWallpaperComponentLocked 方法内增加红色标示的代码。即修改成如下:
ServiceInfo si = mIPackageManager.getServiceInfo(componentName,
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS, serviceUserId);
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS, serviceUserId);
//add for change default wallpaper
if (si==null)
{
componentName = IMAGE_WALLPAPER;
si = mIPackageManager.getServiceInfo(componentName,
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS, serviceUserId);
}
{
componentName = IMAGE_WALLPAPER;
si = mIPackageManager.getServiceInfo(componentName,
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS, serviceUserId);
}
//add for change default wallpaper
if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) {
String msg = "Selected service does not require "
+ android.Manifest.permission.BIND_WALLPAPER
+ ": " + componentName;
if (fromUser) {
throw new SecurityException(msg);
}
Slog.w(TAG, msg);
return false;
}
if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) {
String msg = "Selected service does not require "
+ android.Manifest.permission.BIND_WALLPAPER
+ ": " + componentName;
if (fromUser) {
throw new SecurityException(msg);
}
Slog.w(TAG, msg);
return false;
}
做以上修改后,手机不会重启,并恢复到默认的静态壁纸。
Android 如何解决默认壁纸更改为ImageWallpaper之外的壁纸,在特定的操作下,导致死机的问题。,布布扣,bubuko.com