• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 com.android.networkstack.apishim.common;
18 
19 import android.net.IpPrefix;
20 import android.net.LinkProperties;
21 import android.net.Network;
22 import android.net.NetworkCapabilities;
23 import android.net.Uri;
24 
25 import androidx.annotation.NonNull;
26 import androidx.annotation.Nullable;
27 
28 import java.net.Inet4Address;
29 import java.util.List;
30 
31 /**
32  * Compatibility interface for network info classes such as {@link LinkProperties} and
33  * {@link NetworkCapabilities}.
34  */
35 public interface NetworkInformationShim {
36     /**
37      * @see LinkProperties#getCaptivePortalApiUrl()
38      */
39     @Nullable
getCaptivePortalApiUrl(@ullable LinkProperties lp)40     Uri getCaptivePortalApiUrl(@Nullable LinkProperties lp);
41 
42     /**
43      * @see LinkProperties#setCaptivePortalApiUrl(Uri)
44      */
setCaptivePortalApiUrl(@onNull LinkProperties lp, @Nullable Uri url)45     void setCaptivePortalApiUrl(@NonNull LinkProperties lp, @Nullable Uri url);
46 
47     /**
48      * @see LinkProperties#getCaptivePortalData()
49      */
50     @Nullable
getCaptivePortalData(@ullable LinkProperties lp)51     CaptivePortalDataShim getCaptivePortalData(@Nullable LinkProperties lp);
52 
53     /**
54      * @see LinkProperties#getNat64Prefix()
55      */
56     @Nullable
getNat64Prefix(@onNull LinkProperties lp)57     IpPrefix getNat64Prefix(@NonNull LinkProperties lp);
58 
59     /**
60      * @see LinkProperties#setNat64Prefix()
61      */
setNat64Prefix(@onNull LinkProperties lp, @Nullable IpPrefix prefix)62     void setNat64Prefix(@NonNull LinkProperties lp, @Nullable IpPrefix prefix);
63 
64     /**
65      * @see NetworkCapabilities#getSSID()
66      */
67     @Nullable
getSsid(@ullable NetworkCapabilities nc)68     String getSsid(@Nullable NetworkCapabilities nc);
69 
70     /**
71      * @see LinkProperties#LinkProperties(LinkProperties, boolean)
72      */
73     @NonNull
makeSensitiveFieldsParcelingCopy(@onNull LinkProperties lp)74     LinkProperties makeSensitiveFieldsParcelingCopy(@NonNull LinkProperties lp);
75 
76     /**
77      * @see LinkProperties#setDhcpServerAddress()
78      */
setDhcpServerAddress(@onNull LinkProperties lp, @NonNull Inet4Address serverAddress)79     void setDhcpServerAddress(@NonNull LinkProperties lp, @NonNull Inet4Address serverAddress);
80 
81     /**
82      * Set captive portal data in {@link LinkProperties}
83      * @param lp Link properties object to be updated
84      * @param captivePortalData Captive portal data to be used
85      */
setCaptivePortalData(@onNull LinkProperties lp, @Nullable CaptivePortalDataShim captivePortalData)86     void setCaptivePortalData(@NonNull LinkProperties lp,
87             @Nullable CaptivePortalDataShim captivePortalData);
88 
89     /**
90      * Get the name of the given capability that carriers use.
91      * If the capability does not have a carrier-name, returns null.
92      *
93      * @param capability The capability to get the carrier-name of.
94      * @return The carrier-name of the capability, or null if it doesn't exist.
95      * @hide
96      */
97     @Nullable
getCapabilityCarrierName(int capability)98     default String getCapabilityCarrierName(int capability) {
99         return null;
100     }
101 
102     /**
103      * @see NetworkCapabilities#getUnderlyingNetworks()
104      */
105     @Nullable
getUnderlyingNetworks(@onNull NetworkCapabilities nc)106     default List<Network> getUnderlyingNetworks(@NonNull NetworkCapabilities nc) {
107         return null;
108     }
109 }
110