summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChing Sung Li <chriscsli@google.com>2019-03-14 01:22:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-03-14 01:22:35 +0000
commitf74466ed9c1ad498711a1bf6291cbf0d61783bb4 (patch)
tree00344b3b8ffd07016d2aa0988f367761b448ab3f
parentd749704acc5c3feab4a385706fcb6238a5c32760 (diff)
parent27efe4c848c662a33463f38573e8078cebf39e02 (diff)
downloadandroid_packages_wallpapers_LivePicker-f74466ed9c1ad498711a1bf6291cbf0d61783bb4.tar.gz
android_packages_wallpapers_LivePicker-f74466ed9c1ad498711a1bf6291cbf0d61783bb4.tar.bz2
android_packages_wallpapers_LivePicker-f74466ed9c1ad498711a1bf6291cbf0d61783bb4.zip
Merge "Hide deletion action for currently set Live wallpaper"
-rw-r--r--src/com/android/wallpaper/livepicker/LiveWallpaperChange.java14
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);