diff options
author | Ching-Sung Li <chriscsli@google.com> | 2019-03-04 09:54:11 +0800 |
---|---|---|
committer | Ching-Sung Li <chriscsli@google.com> | 2019-03-12 21:48:05 +0800 |
commit | 27efe4c848c662a33463f38573e8078cebf39e02 (patch) | |
tree | a0d5b5227aadbfdaba5fdc3d379a7d16e7032b7a | |
parent | d21c55c0a148e20ace3672a5e0a984846a26fc85 (diff) | |
download | android_packages_wallpapers_LivePicker-27efe4c848c662a33463f38573e8078cebf39e02.tar.gz android_packages_wallpapers_LivePicker-27efe4c848c662a33463f38573e8078cebf39e02.tar.bz2 android_packages_wallpapers_LivePicker-27efe4c848c662a33463f38573e8078cebf39e02.zip |
Hide deletion action for currently set Live wallpaper
Hide deletion action for currently set Live wallpaper in LivePicker
Bug: 126453855
Test: Manual
Change-Id: I7c35f2820819c66f7377c4c9843d8d6646670953
-rw-r--r-- | src/com/android/wallpaper/livepicker/LiveWallpaperChange.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/com/android/wallpaper/livepicker/LiveWallpaperChange.java b/src/com/android/wallpaper/livepicker/LiveWallpaperChange.java index 412dabd..c25875f 100644 --- a/src/com/android/wallpaper/livepicker/LiveWallpaperChange.java +++ b/src/com/android/wallpaper/livepicker/LiveWallpaperChange.java @@ -26,6 +26,7 @@ import android.content.pm.ServiceInfo; import android.os.Bundle; import android.os.Parcelable; import android.service.wallpaper.WallpaperService; +import android.text.TextUtils; import android.util.Log; import androidx.annotation.NonNull; @@ -51,6 +52,7 @@ public class LiveWallpaperChange extends LiveWallpaperPreview { } ComponentName comp = (ComponentName)obj; + WallpaperInfo currentWallpaper = WallpaperManager.getInstance(this).getWallpaperInfo(); // Get the information about this component. Implemented this way // to not allow us to direct the caller to a service that is not a @@ -71,7 +73,8 @@ public class LiveWallpaperChange extends LiveWallpaperPreview { finish(); return; } - initUI(info, getDeleteAction(ri.serviceInfo)); + initUI(info, getDeleteAction(ri.serviceInfo, + (currentWallpaper == null) ? null : currentWallpaper.getServiceInfo())); return; } } @@ -82,8 +85,15 @@ public class LiveWallpaperChange extends LiveWallpaperPreview { } @Nullable - private String getDeleteAction(@NonNull ServiceInfo serviceInfo) { + private String getDeleteAction(@NonNull ServiceInfo serviceInfo, + @Nullable ServiceInfo currentService) { // STOPSHIP: Check this wallpaper is pre-installed before providing delete action. + + // A currently set Live wallpaper should not be deleted. + if (currentService != null && TextUtils.equals(serviceInfo.name, currentService.name)) { + return null; + } + final Bundle metaData = serviceInfo.metaData; if (metaData != null) { return metaData.getString(KEY_ACTION_DELETE_LIVE_WALLPAPER); |