Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae7bf51a authored by SzuWei Lin's avatar SzuWei Lin Committed by android-build-merger
Browse files

Merge "Nullify the default wallpaper component if it does not exist"

am: b25a4d60

Change-Id: I9a01944dec9c5e6c3366ddf62e9bc9a04e757e4f
parents 1f12c311 b25a4d60
Loading
Loading
Loading
Loading
+19 −9
Original line number Original line Diff line number Diff line
@@ -1885,23 +1885,33 @@ public class WallpaperManager {
     * @hide
     * @hide
     */
     */
    public static ComponentName getDefaultWallpaperComponent(Context context) {
    public static ComponentName getDefaultWallpaperComponent(Context context) {
        ComponentName cn = null;

        String flat = SystemProperties.get(PROP_WALLPAPER_COMPONENT);
        String flat = SystemProperties.get(PROP_WALLPAPER_COMPONENT);
        if (!TextUtils.isEmpty(flat)) {
        if (!TextUtils.isEmpty(flat)) {
            final ComponentName cn = ComponentName.unflattenFromString(flat);
            cn = ComponentName.unflattenFromString(flat);
            if (cn != null) {
                return cn;
            }
        }
        }


        if (cn == null) {
            flat = context.getString(com.android.internal.R.string.default_wallpaper_component);
            flat = context.getString(com.android.internal.R.string.default_wallpaper_component);
            if (!TextUtils.isEmpty(flat)) {
            if (!TextUtils.isEmpty(flat)) {
            final ComponentName cn = ComponentName.unflattenFromString(flat);
                cn = ComponentName.unflattenFromString(flat);
            }
        }

        // Check if the package exists
        if (cn != null) {
        if (cn != null) {
                return cn;
            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;
    }
    }


    /**
    /**