Make WallpaperPreferenceController available when only style picker present.

WallpaperPreferenceController prefers the style picker over the basic wallpaper picker. However, the entire setting is disabled when only the style picker is available, even though the basic wallpaper picker is not used. This change corrects that.

Fixes: 162395248
Test: Added unit tests. Also built, flashed and tested setting with all four combinations of CategoryPickerActivity and CustomizationPickerActivity enabled/disabled.
Change-Id: I4184f834ed771359cef13b64aacf2072e592d6d8
This commit is contained in:
Matthew Mintz
2020-07-29 17:39:47 +08:00
parent c1a0293028
commit 3243920695
2 changed files with 51 additions and 6 deletions

View File

@@ -62,8 +62,11 @@ public class WallpaperPreferenceController extends BasePreferenceController {
}
public ComponentName getComponentName() {
return new ComponentName(mWallpaperPackage,
areStylesAvailable() ? mStylesAndWallpaperClass : mWallpaperClass);
return new ComponentName(mWallpaperPackage, getComponentClassString());
}
public String getComponentClassString() {
return areStylesAvailable() ? mStylesAndWallpaperClass : mWallpaperClass;
}
public String getKeywords() {
@@ -76,11 +79,12 @@ public class WallpaperPreferenceController extends BasePreferenceController {
@Override
public int getAvailabilityStatus() {
if (TextUtils.isEmpty(mWallpaperPackage) || TextUtils.isEmpty(mWallpaperClass)) {
if ((TextUtils.isEmpty(mWallpaperClass) && TextUtils.isEmpty(mStylesAndWallpaperClass))
|| TextUtils.isEmpty(mWallpaperPackage)) {
Log.e(TAG, "No Wallpaper picker specified!");
return UNSUPPORTED_ON_DEVICE;
}
return canResolveWallpaperComponent(mWallpaperClass)
return canResolveWallpaperComponent(getComponentClassString())
? AVAILABLE_UNSEARCHABLE : CONDITIONALLY_UNAVAILABLE;
}