1 /* 2 * Copyright (C) 2017 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 com.android.settings.intelligence.search.savedqueries; 18 19 import android.os.Parcel; 20 import androidx.annotation.VisibleForTesting; 21 22 import com.android.settings.intelligence.search.ResultPayload; 23 24 /** 25 * {@link ResultPayload} for saved query. 26 */ 27 public class SavedQueryPayload extends ResultPayload { 28 29 public final String query; 30 SavedQueryPayload(String query)31 public SavedQueryPayload(String query) { 32 super(null /* Intent */); 33 this.query = query; 34 } 35 36 @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) SavedQueryPayload(Parcel in)37 SavedQueryPayload(Parcel in) { 38 super(null /* Intent */); 39 query = in.readString(); 40 } 41 42 @Override getType()43 public int getType() { 44 return PayloadType.SAVED_QUERY; 45 } 46 47 @Override describeContents()48 public int describeContents() { 49 return 0; 50 } 51 52 @Override writeToParcel(Parcel dest, int flags)53 public void writeToParcel(Parcel dest, int flags) { 54 dest.writeString(query); 55 } 56 57 public static final Creator<SavedQueryPayload> CREATOR = new Creator<SavedQueryPayload>() { 58 @Override 59 public SavedQueryPayload createFromParcel(Parcel in) { 60 return new SavedQueryPayload(in); 61 } 62 63 @Override 64 public SavedQueryPayload[] newArray(int size) { 65 return new SavedQueryPayload[size]; 66 } 67 }; 68 } 69