Merge "Nullify the default wallpaper component if it does not exist" into pi-dev

This commit is contained in:
TreeHugger Robot
2019-01-11 03:36:19 +00:00
committed by Android (Google) Code Review

View File

@@ -1874,23 +1874,33 @@ public class WallpaperManager {
* @hide
*/
public static ComponentName getDefaultWallpaperComponent(Context context) {
ComponentName cn = null;
String flat = SystemProperties.get(PROP_WALLPAPER_COMPONENT);
if (!TextUtils.isEmpty(flat)) {
final ComponentName cn = ComponentName.unflattenFromString(flat);
if (cn != null) {
return cn;
cn = ComponentName.unflattenFromString(flat);
}
if (cn == null) {
flat = context.getString(com.android.internal.R.string.default_wallpaper_component);
if (!TextUtils.isEmpty(flat)) {
cn = ComponentName.unflattenFromString(flat);
}
}
flat = context.getString(com.android.internal.R.string.default_wallpaper_component);
if (!TextUtils.isEmpty(flat)) {
final ComponentName cn = ComponentName.unflattenFromString(flat);
if (cn != null) {
return cn;
// Check if the package exists
if (cn != null) {
try {
final PackageManager packageManager = context.getPackageManager();
packageManager.getPackageInfo(cn.getPackageName(),
PackageManager.MATCH_DIRECT_BOOT_AWARE
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE);
} catch (PackageManager.NameNotFoundException e) {
cn = null;
}
}
return null;
return cn;
}
/**