• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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}
27  * assigned to it; these are typically {@link android.os.Parcelable} classes
28  * which need to be updated after crossing Binder transaction boundaries.
29  *
30  * @hide
31  */
32 public interface Attributable {
33     /** @hide */
setAttributionSource(@onNull AttributionSource attributionSource)34     void setAttributionSource(@NonNull AttributionSource attributionSource);
35 
36     /** @hide */
setAttributionSource( @ullable T attributable, @NonNull AttributionSource attributionSource)37     static @Nullable <T extends Attributable> T setAttributionSource(
38             @Nullable T attributable,
39             @NonNull AttributionSource attributionSource) {
40         if (attributable != null) {
41             attributable.setAttributionSource(attributionSource);
42         }
43         return attributable;
44     }
45 
46     /** @hide */
setAttributionSource( @ullable List<T> attributableList, @NonNull AttributionSource attributionSource)47     static @Nullable <T extends Attributable> List<T> setAttributionSource(
48             @Nullable List<T> attributableList,
49             @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