1 /* 2 * Copyright (C) 2022 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 17 package android.app.wallpapereffectsgeneration; 18 19 import android.annotation.NonNull; 20 import android.annotation.SystemApi; 21 import android.graphics.Bitmap; 22 import android.os.Parcel; 23 import android.os.Parcelable; 24 25 import java.util.Objects; 26 27 /** 28 * A {@link CinematicEffectRequest} is the data class having all the information 29 * passed to wallpaper effects generation service. 30 * 31 * @hide 32 */ 33 @SystemApi 34 public final class CinematicEffectRequest implements Parcelable { 35 /** 36 * Unique id of a cienmatic effect generation task. 37 */ 38 @NonNull 39 private String mTaskId; 40 41 /** 42 * The bitmap to generate cinematic effect from. 43 */ 44 @NonNull 45 private Bitmap mBitmap; 46 CinematicEffectRequest(Parcel in)47 private CinematicEffectRequest(Parcel in) { 48 this.mTaskId = in.readString(); 49 this.mBitmap = Bitmap.CREATOR.createFromParcel(in); 50 } 51 52 /** 53 * Constructor with task id and bitmap. 54 */ CinematicEffectRequest(@onNull String taskId, @NonNull Bitmap bitmap)55 public CinematicEffectRequest(@NonNull String taskId, @NonNull Bitmap bitmap) { 56 mTaskId = taskId; 57 mBitmap = bitmap; 58 } 59 60 /** 61 * Returns the task id. 62 */ 63 @NonNull getTaskId()64 public String getTaskId() { 65 return mTaskId; 66 } 67 68 /** 69 * Returns the bitmap of this request. 70 */ 71 @NonNull getBitmap()72 public Bitmap getBitmap() { 73 return mBitmap; 74 } 75 76 @Override equals(Object o)77 public boolean equals(Object o) { 78 if (this == o) return true; 79 if (o == null || getClass() != o.getClass()) { 80 return false; 81 } 82 CinematicEffectRequest that = (CinematicEffectRequest) o; 83 return mTaskId.equals(that.mTaskId); 84 } 85 86 @Override hashCode()87 public int hashCode() { 88 return Objects.hash(mTaskId); 89 } 90 91 @Override describeContents()92 public int describeContents() { 93 return 0; 94 } 95 96 @Override writeToParcel(@onNull Parcel out, int flags)97 public void writeToParcel(@NonNull Parcel out, int flags) { 98 out.writeString(mTaskId); 99 mBitmap.writeToParcel(out, flags); 100 } 101 102 @NonNull 103 public static final Creator<CinematicEffectRequest> CREATOR = 104 new Creator<CinematicEffectRequest>() { 105 @Override 106 public CinematicEffectRequest createFromParcel(Parcel in) { 107 return new CinematicEffectRequest(in); 108 } 109 110 @Override 111 public CinematicEffectRequest[] newArray(int size) { 112 return new CinematicEffectRequest[size]; 113 } 114 }; 115 } 116