• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.net;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 
22 /**
23  * A container for transport-specific capabilities which is returned by
24  * {@link NetworkCapabilities#getTransportInfo()}. Specific networks
25  * may provide concrete implementations of this interface.
26  * @see android.net.wifi.aware.WifiAwareNetworkInfo
27  * @see android.net.wifi.WifiInfo
28  */
29 public interface TransportInfo {
30 
31     /**
32      * Create a copy of a {@link TransportInfo} with some fields redacted based on the permissions
33      * held by the receiving app.
34      *
35      * <p>
36      * Usage by connectivity stack:
37      * <ul>
38      * <li> Connectivity stack will invoke {@link #getApplicableRedactions()} to find the list
39      * of redactions that are required by this {@link TransportInfo} instance.</li>
40      * <li> Connectivity stack then loops through each bit in the bitmask returned and checks if the
41      * receiving app holds the corresponding permission.
42      * <ul>
43      * <li> If the app holds the corresponding permission, the bit is cleared from the
44      * |redactions| bitmask. </li>
45      * <li> If the app does not hold the corresponding permission, the bit is retained in the
46      * |redactions| bitmask. </li>
47      * </ul>
48      * <li> Connectivity stack then invokes {@link #makeCopy(long)} with the necessary |redactions|
49      * to create a copy to send to the corresponding app. </li>
50      * </ul>
51      * </p>
52      *
53      * @param redactions bitmask of redactions that needs to be performed on this instance.
54      * @return Copy of this instance with the necessary redactions.
55      * @hide
56      */
57     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
58     @NonNull
makeCopy(@etworkCapabilities.RedactionType long redactions)59     default TransportInfo makeCopy(@NetworkCapabilities.RedactionType long redactions) {
60         return this;
61     }
62 
63     /**
64      * Returns a bitmask of all the applicable redactions (based on the permissions held by the
65      * receiving app) to be performed on this TransportInfo.
66      *
67      * @return bitmask of redactions applicable on this instance.
68      * @see #makeCopy(long)
69      * @hide
70      */
71     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
getApplicableRedactions()72     default @NetworkCapabilities.RedactionType long getApplicableRedactions() {
73         return NetworkCapabilities.REDACT_NONE;
74     }
75 }
76