1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.wallpaper.model; 17 18 import android.app.WallpaperInfo; 19 import android.app.wallpaper.WallpaperDescription; 20 import android.graphics.Point; 21 import android.graphics.Rect; 22 import android.net.Uri; 23 24 import androidx.annotation.NonNull; 25 import androidx.annotation.Nullable; 26 27 import java.util.List; 28 import java.util.Map; 29 30 /** 31 * Live wallpaper-specific wrapper for user-facing wallpaper metadata. 32 */ 33 public class LiveWallpaperMetadata extends WallpaperMetadata { 34 @Nullable private final Uri mPreviewUri; 35 @NonNull private final WallpaperDescription mDescription; 36 LiveWallpaperMetadata(android.app.WallpaperInfo wallpaperComponent, @Nullable Uri previewUri)37 public LiveWallpaperMetadata(android.app.WallpaperInfo wallpaperComponent, 38 @Nullable Uri previewUri) { 39 this(wallpaperComponent, previewUri, 40 new WallpaperDescription.Builder().setComponent( 41 wallpaperComponent.getComponent()).build()); 42 } 43 LiveWallpaperMetadata(android.app.WallpaperInfo wallpaperComponent, @Nullable Uri previewUri, @NonNull WallpaperDescription description)44 public LiveWallpaperMetadata(android.app.WallpaperInfo wallpaperComponent, 45 @Nullable Uri previewUri, @NonNull WallpaperDescription description) { 46 super(null, null, null, wallpaperComponent, null, null); 47 mPreviewUri = previewUri; 48 mDescription = description; 49 } 50 51 @Override getAttributions()52 public List<String> getAttributions() { 53 throw new UnsupportedOperationException("Not implemented for live wallpapers"); 54 } 55 56 @Override getActionUrl()57 public String getActionUrl() { 58 throw new UnsupportedOperationException("Not implemented for live wallpapers"); 59 } 60 61 @Override getCollectionId()62 public String getCollectionId() { 63 throw new UnsupportedOperationException("Not implemented for live wallpapers"); 64 } 65 66 @Override getWallpaperComponent()67 public WallpaperInfo getWallpaperComponent() { 68 return mWallpaperComponent; 69 } 70 71 @Nullable 72 @Override getWallpaperCropHints()73 public Map<Point, Rect> getWallpaperCropHints() { 74 throw new UnsupportedOperationException("Not implemented for live wallpapers"); 75 } 76 77 @Nullable 78 @Override getWallpaperImageUri()79 public Uri getWallpaperImageUri() { 80 throw new UnsupportedOperationException("Not implemented for live wallpapers"); 81 } 82 83 @Nullable getPreviewUri()84 public Uri getPreviewUri() { 85 return mPreviewUri; 86 } 87 88 @NonNull getDescription()89 public WallpaperDescription getDescription() { 90 return mDescription; 91 } 92 } 93