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 17 package android.bluetooth; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.content.AttributionSource; 22 23 import java.util.List; 24 25 /** 26 * Marker interface for a class which can have an {@link AttributionSource} assigned to it; these 27 * are typically {@link android.os.Parcelable} classes which need to be updated after crossing 28 * Binder transaction boundaries. 29 * 30 * @hide 31 */ 32 public interface Attributable { 33 /** @hide */ 34 @SuppressWarnings("AmbiguousMethodReference") setAttributionSource(@onNull AttributionSource attributionSource)35 void setAttributionSource(@NonNull AttributionSource attributionSource); 36 37 /** @hide */ 38 @SuppressWarnings("AmbiguousMethodReference") setAttributionSource( @ullable T attributable, @NonNull AttributionSource attributionSource)39 static @Nullable <T extends Attributable> T setAttributionSource( 40 @Nullable T attributable, @NonNull AttributionSource attributionSource) { 41 if (attributable != null) { 42 attributable.setAttributionSource(attributionSource); 43 } 44 return attributable; 45 } 46 47 /** @hide */ setAttributionSource( @ullable List<T> attributableList, @NonNull AttributionSource attributionSource)48 static @Nullable <T extends Attributable> List<T> setAttributionSource( 49 @Nullable List<T> attributableList, @NonNull AttributionSource attributionSource) { 50 if (attributableList != null) { 51 final int size = attributableList.size(); 52 for (int i = 0; i < size; i++) { 53 setAttributionSource(attributableList.get(i), attributionSource); 54 } 55 } 56 return attributableList; 57 } 58 } 59