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 android.content.pm; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 import java.util.Collections; 23 import java.util.List; 24 25 /** 26 * Transfer a large list of Parcelable objects across an IPC. Splits into 27 * multiple transactions if needed. 28 * 29 * @see BaseParceledListSlice 30 * 31 * @hide 32 */ 33 public class StringParceledListSlice extends BaseParceledListSlice<String> { 34 public StringParceledListSlice(List<String> list) { 35 super(list); 36 } 37 38 private StringParceledListSlice(Parcel in, ClassLoader loader) { 39 super(in, loader); 40 } 41 42 public static StringParceledListSlice emptyList() { 43 return new StringParceledListSlice(Collections.<String> emptyList()); 44 } 45 46 @Override 47 public int describeContents() { 48 return 0; 49 } 50 51 @Override 52 protected void writeElement(String parcelable, Parcel reply, int callFlags) { 53 reply.writeString(parcelable); 54 } 55 56 @Override 57 protected void writeParcelableCreator(String parcelable, Parcel dest) { 58 return; 59 } 60 61 @Override 62 protected Parcelable.Creator<?> readParcelableCreator(Parcel from, ClassLoader loader) { 63 return Parcel.STRING_CREATOR; 64 } 65 66 @SuppressWarnings("unchecked") 67 public static final Parcelable.ClassLoaderCreator<StringParceledListSlice> CREATOR = 68 new Parcelable.ClassLoaderCreator<StringParceledListSlice>() { 69 public StringParceledListSlice createFromParcel(Parcel in) { 70 return new StringParceledListSlice(in, null); 71 } 72 73 @Override 74 public StringParceledListSlice createFromParcel(Parcel in, ClassLoader loader) { 75 return new StringParceledListSlice(in, loader); 76 } 77 78 @Override 79 public StringParceledListSlice[] newArray(int size) { 80 return new StringParceledListSlice[size]; 81 } 82 }; 83 } 84