Nullify the default wallpaper component if it does not exist

The default wallpaper component cannot be found after GSI is flashed.
The home screen background will have no wallpaper and be black.
It will also cause the following CTS tests to fail:

- KeyguardTests#testDialogShowWhenLockedActivity
- KeyguardTests#testTranslucentShowWhenLockedActivity

The patch will check if the package of the default component exists.
If not, it will fall back to null, which is the AOSP default value, and
display the wallpaper in framework resource.

Bug: 119895131
Bug: 111909699
Test: flash GSI aosp_arm64-userdebug on a crosshatch, got AOSP wallpaper
Test: flash full crosshatch-userdebug on a crosshatch, got crosshatch wallpaper
Change-Id: I9d618d05458a03a675324cb2f861decf31c5bf18
This commit is contained in:
SzuWei Lin
2018-11-22 14:33:01 +08:00
parent 4dd4cf5679
commit 1c7ae31e97

View File

@@ -1885,23 +1885,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;
}
/**