From 27efe4c848c662a33463f38573e8078cebf39e02 Mon Sep 17 00:00:00 2001 From: Ching-Sung Li Date: Mon, 4 Mar 2019 09:54:11 +0800 Subject: 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 --- .../android/wallpaper/livepicker/LiveWallpaperChange.java | 14 ++++++++++++-- 1 file 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); -- cgit v1.2.3