1/* 2 * Copyright (C) 2021 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 17package com.android.bedstead.remoteframeworkclasses; 18 19import android.content.RemoteContentResolver; 20import android.os.Parcel; 21import android.os.Parcelable; 22 23import com.google.android.enterprise.connectedapps.annotations.CustomParcelableWrapper; 24import com.google.android.enterprise.connectedapps.internal.Bundler; 25import com.google.android.enterprise.connectedapps.internal.BundlerType; 26 27/** 28 * This parcelable wrapper just passes null to callers. 29 * 30 * <p>It is not functional and only enables use of {@link RemoteContentResolver} for clients 31 * which do not need to actually use the {@link RemoteContentResolver} param or return value. 32 */ 33@CustomParcelableWrapper(originalType = RemoteContentResolver.class) 34public final class NullParcelableRemoteContentResolver implements Parcelable { 35 36 /** 37 * Create a wrapper for a given {@link RemoteContentResolver}. 38 */ 39 public static <F> NullParcelableRemoteContentResolver of( 40 Bundler bundler, BundlerType type, 41 RemoteContentResolver remoteContentResolver) { 42 return new NullParcelableRemoteContentResolver(); 43 } 44 45 private NullParcelableRemoteContentResolver() { 46 } 47 48 public RemoteContentResolver get() { 49 return null; 50 } 51 52 @Override 53 public void writeToParcel(Parcel dest, int flags) { 54 } 55 56 @Override 57 public int describeContents() { 58 return 0; 59 } 60 61 @SuppressWarnings("rawtypes") 62 public static final Creator<NullParcelableRemoteContentResolver> CREATOR = 63 new Creator<NullParcelableRemoteContentResolver>() { 64 @Override 65 public NullParcelableRemoteContentResolver createFromParcel(Parcel in) { 66 return new NullParcelableRemoteContentResolver(); 67 } 68 69 @Override 70 public NullParcelableRemoteContentResolver[] newArray(int size) { 71 return new NullParcelableRemoteContentResolver[size]; 72 } 73 }; 74}