Merge "Add nullability annotations to public methods of ConnManager." am: 805e2ad9db
am: 85188cead6
Change-Id: If2e704e1f8ddf504be9e777ec226b2ce524438dc
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
import android.annotation.SdkConstant;
|
import android.annotation.SdkConstant;
|
||||||
@@ -909,6 +910,7 @@ public class ConnectivityManager {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
|
@Nullable
|
||||||
public NetworkInfo getActiveNetworkInfo() {
|
public NetworkInfo getActiveNetworkInfo() {
|
||||||
try {
|
try {
|
||||||
return mService.getActiveNetworkInfo();
|
return mService.getActiveNetworkInfo();
|
||||||
@@ -928,6 +930,7 @@ public class ConnectivityManager {
|
|||||||
* {@code null} if no default network is currently active
|
* {@code null} if no default network is currently active
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
|
@Nullable
|
||||||
public Network getActiveNetwork() {
|
public Network getActiveNetwork() {
|
||||||
try {
|
try {
|
||||||
return mService.getActiveNetwork();
|
return mService.getActiveNetwork();
|
||||||
@@ -949,6 +952,7 @@ public class ConnectivityManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL)
|
@RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL)
|
||||||
|
@Nullable
|
||||||
public Network getActiveNetworkForUid(int uid) {
|
public Network getActiveNetworkForUid(int uid) {
|
||||||
return getActiveNetworkForUid(uid, false);
|
return getActiveNetworkForUid(uid, false);
|
||||||
}
|
}
|
||||||
@@ -1074,6 +1078,7 @@ public class ConnectivityManager {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
|
@Nullable
|
||||||
public NetworkInfo getNetworkInfo(int networkType) {
|
public NetworkInfo getNetworkInfo(int networkType) {
|
||||||
try {
|
try {
|
||||||
return mService.getNetworkInfo(networkType);
|
return mService.getNetworkInfo(networkType);
|
||||||
@@ -1095,7 +1100,8 @@ public class ConnectivityManager {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
public NetworkInfo getNetworkInfo(Network network) {
|
@Nullable
|
||||||
|
public NetworkInfo getNetworkInfo(@Nullable Network network) {
|
||||||
return getNetworkInfoForUid(network, Process.myUid(), false);
|
return getNetworkInfoForUid(network, Process.myUid(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1121,6 +1127,7 @@ public class ConnectivityManager {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
|
@NonNull
|
||||||
public NetworkInfo[] getAllNetworkInfo() {
|
public NetworkInfo[] getAllNetworkInfo() {
|
||||||
try {
|
try {
|
||||||
return mService.getAllNetworkInfo();
|
return mService.getAllNetworkInfo();
|
||||||
@@ -1156,6 +1163,7 @@ public class ConnectivityManager {
|
|||||||
* @return an array of {@link Network} objects.
|
* @return an array of {@link Network} objects.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
|
@NonNull
|
||||||
public Network[] getAllNetworks() {
|
public Network[] getAllNetworks() {
|
||||||
try {
|
try {
|
||||||
return mService.getAllNetworks();
|
return mService.getAllNetworks();
|
||||||
@@ -1230,7 +1238,8 @@ public class ConnectivityManager {
|
|||||||
* @return The {@link LinkProperties} for the network, or {@code null}.
|
* @return The {@link LinkProperties} for the network, or {@code null}.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
public LinkProperties getLinkProperties(Network network) {
|
@Nullable
|
||||||
|
public LinkProperties getLinkProperties(@Nullable Network network) {
|
||||||
try {
|
try {
|
||||||
return mService.getLinkProperties(network);
|
return mService.getLinkProperties(network);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -1246,7 +1255,8 @@ public class ConnectivityManager {
|
|||||||
* @return The {@link android.net.NetworkCapabilities} for the network, or {@code null}.
|
* @return The {@link android.net.NetworkCapabilities} for the network, or {@code null}.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
public NetworkCapabilities getNetworkCapabilities(Network network) {
|
@Nullable
|
||||||
|
public NetworkCapabilities getNetworkCapabilities(@Nullable Network network) {
|
||||||
try {
|
try {
|
||||||
return mService.getNetworkCapabilities(network);
|
return mService.getNetworkCapabilities(network);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -2000,7 +2010,7 @@ public class ConnectivityManager {
|
|||||||
*
|
*
|
||||||
* @param l Previously registered listener.
|
* @param l Previously registered listener.
|
||||||
*/
|
*/
|
||||||
public void removeDefaultNetworkActiveListener(OnNetworkActiveListener l) {
|
public void removeDefaultNetworkActiveListener(@NonNull OnNetworkActiveListener l) {
|
||||||
INetworkActivityListener rl = mNetworkActivityListeners.get(l);
|
INetworkActivityListener rl = mNetworkActivityListeners.get(l);
|
||||||
Preconditions.checkArgument(rl != null, "Listener was not registered.");
|
Preconditions.checkArgument(rl != null, "Listener was not registered.");
|
||||||
try {
|
try {
|
||||||
@@ -2528,7 +2538,7 @@ public class ConnectivityManager {
|
|||||||
* working and non-working connectivity.
|
* working and non-working connectivity.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void reportBadNetwork(Network network) {
|
public void reportBadNetwork(@Nullable Network network) {
|
||||||
printStackTrace();
|
printStackTrace();
|
||||||
try {
|
try {
|
||||||
// One of these will be ignored because it matches system's current state.
|
// One of these will be ignored because it matches system's current state.
|
||||||
@@ -2551,7 +2561,7 @@ public class ConnectivityManager {
|
|||||||
* @param hasConnectivity {@code true} if the application was able to successfully access the
|
* @param hasConnectivity {@code true} if the application was able to successfully access the
|
||||||
* Internet using {@code network} or {@code false} if not.
|
* Internet using {@code network} or {@code false} if not.
|
||||||
*/
|
*/
|
||||||
public void reportNetworkConnectivity(Network network, boolean hasConnectivity) {
|
public void reportNetworkConnectivity(@Nullable Network network, boolean hasConnectivity) {
|
||||||
printStackTrace();
|
printStackTrace();
|
||||||
try {
|
try {
|
||||||
mService.reportNetworkConnectivity(network, hasConnectivity);
|
mService.reportNetworkConnectivity(network, hasConnectivity);
|
||||||
@@ -2625,6 +2635,7 @@ public class ConnectivityManager {
|
|||||||
* @return the {@link ProxyInfo} for the current HTTP proxy, or {@code null} if no
|
* @return the {@link ProxyInfo} for the current HTTP proxy, or {@code null} if no
|
||||||
* HTTP proxy is active.
|
* HTTP proxy is active.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public ProxyInfo getDefaultProxy() {
|
public ProxyInfo getDefaultProxy() {
|
||||||
return getProxyForNetwork(getBoundNetworkForProcess());
|
return getProxyForNetwork(getBoundNetworkForProcess());
|
||||||
}
|
}
|
||||||
@@ -3156,8 +3167,9 @@ public class ConnectivityManager {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void requestNetwork(NetworkRequest request, NetworkCallback networkCallback,
|
public void requestNetwork(@NonNull NetworkRequest request,
|
||||||
int timeoutMs, int legacyType, Handler handler) {
|
@NonNull NetworkCallback networkCallback, int timeoutMs, int legacyType,
|
||||||
|
@NonNull Handler handler) {
|
||||||
CallbackHandler cbHandler = new CallbackHandler(handler);
|
CallbackHandler cbHandler = new CallbackHandler(handler);
|
||||||
NetworkCapabilities nc = request.networkCapabilities;
|
NetworkCapabilities nc = request.networkCapabilities;
|
||||||
sendRequestForNetwork(nc, networkCallback, timeoutMs, REQUEST, legacyType, cbHandler);
|
sendRequestForNetwork(nc, networkCallback, timeoutMs, REQUEST, legacyType, cbHandler);
|
||||||
@@ -3194,7 +3206,8 @@ public class ConnectivityManager {
|
|||||||
* @throws IllegalArgumentException if {@code request} specifies any mutable
|
* @throws IllegalArgumentException if {@code request} specifies any mutable
|
||||||
* {@code NetworkCapabilities}.
|
* {@code NetworkCapabilities}.
|
||||||
*/
|
*/
|
||||||
public void requestNetwork(NetworkRequest request, NetworkCallback networkCallback) {
|
public void requestNetwork(@NonNull NetworkRequest request,
|
||||||
|
@NonNull NetworkCallback networkCallback) {
|
||||||
requestNetwork(request, networkCallback, getDefaultHandler());
|
requestNetwork(request, networkCallback, getDefaultHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3229,8 +3242,8 @@ public class ConnectivityManager {
|
|||||||
* @throws IllegalArgumentException if {@code request} specifies any mutable
|
* @throws IllegalArgumentException if {@code request} specifies any mutable
|
||||||
* {@code NetworkCapabilities}.
|
* {@code NetworkCapabilities}.
|
||||||
*/
|
*/
|
||||||
public void requestNetwork(
|
public void requestNetwork(@NonNull NetworkRequest request,
|
||||||
NetworkRequest request, NetworkCallback networkCallback, Handler handler) {
|
@NonNull NetworkCallback networkCallback, @NonNull Handler handler) {
|
||||||
int legacyType = inferLegacyTypeForNetworkCapabilities(request.networkCapabilities);
|
int legacyType = inferLegacyTypeForNetworkCapabilities(request.networkCapabilities);
|
||||||
CallbackHandler cbHandler = new CallbackHandler(handler);
|
CallbackHandler cbHandler = new CallbackHandler(handler);
|
||||||
requestNetwork(request, networkCallback, 0, legacyType, cbHandler);
|
requestNetwork(request, networkCallback, 0, legacyType, cbHandler);
|
||||||
@@ -3264,8 +3277,8 @@ public class ConnectivityManager {
|
|||||||
* before {@link NetworkCallback#onUnavailable()} is called. The timeout must
|
* before {@link NetworkCallback#onUnavailable()} is called. The timeout must
|
||||||
* be a positive value (i.e. >0).
|
* be a positive value (i.e. >0).
|
||||||
*/
|
*/
|
||||||
public void requestNetwork(NetworkRequest request, NetworkCallback networkCallback,
|
public void requestNetwork(@NonNull NetworkRequest request,
|
||||||
int timeoutMs) {
|
@NonNull NetworkCallback networkCallback, int timeoutMs) {
|
||||||
checkTimeout(timeoutMs);
|
checkTimeout(timeoutMs);
|
||||||
int legacyType = inferLegacyTypeForNetworkCapabilities(request.networkCapabilities);
|
int legacyType = inferLegacyTypeForNetworkCapabilities(request.networkCapabilities);
|
||||||
requestNetwork(request, networkCallback, timeoutMs, legacyType, getDefaultHandler());
|
requestNetwork(request, networkCallback, timeoutMs, legacyType, getDefaultHandler());
|
||||||
@@ -3298,8 +3311,8 @@ public class ConnectivityManager {
|
|||||||
* @param timeoutMs The time in milliseconds to attempt looking for a suitable network
|
* @param timeoutMs The time in milliseconds to attempt looking for a suitable network
|
||||||
* before {@link NetworkCallback#onUnavailable} is called.
|
* before {@link NetworkCallback#onUnavailable} is called.
|
||||||
*/
|
*/
|
||||||
public void requestNetwork(NetworkRequest request, NetworkCallback networkCallback,
|
public void requestNetwork(@NonNull NetworkRequest request,
|
||||||
Handler handler, int timeoutMs) {
|
@NonNull NetworkCallback networkCallback, @NonNull Handler handler, int timeoutMs) {
|
||||||
checkTimeout(timeoutMs);
|
checkTimeout(timeoutMs);
|
||||||
int legacyType = inferLegacyTypeForNetworkCapabilities(request.networkCapabilities);
|
int legacyType = inferLegacyTypeForNetworkCapabilities(request.networkCapabilities);
|
||||||
CallbackHandler cbHandler = new CallbackHandler(handler);
|
CallbackHandler cbHandler = new CallbackHandler(handler);
|
||||||
@@ -3371,7 +3384,8 @@ public class ConnectivityManager {
|
|||||||
* {@link NetworkCapabilities#NET_CAPABILITY_VALIDATED} or
|
* {@link NetworkCapabilities#NET_CAPABILITY_VALIDATED} or
|
||||||
* {@link NetworkCapabilities#NET_CAPABILITY_CAPTIVE_PORTAL}.
|
* {@link NetworkCapabilities#NET_CAPABILITY_CAPTIVE_PORTAL}.
|
||||||
*/
|
*/
|
||||||
public void requestNetwork(NetworkRequest request, PendingIntent operation) {
|
public void requestNetwork(@NonNull NetworkRequest request,
|
||||||
|
@NonNull PendingIntent operation) {
|
||||||
printStackTrace();
|
printStackTrace();
|
||||||
checkPendingIntentNotNull(operation);
|
checkPendingIntentNotNull(operation);
|
||||||
try {
|
try {
|
||||||
@@ -3395,7 +3409,7 @@ public class ConnectivityManager {
|
|||||||
* {@link #requestNetwork(NetworkRequest, android.app.PendingIntent)} with the
|
* {@link #requestNetwork(NetworkRequest, android.app.PendingIntent)} with the
|
||||||
* corresponding NetworkRequest you'd like to remove. Cannot be null.
|
* corresponding NetworkRequest you'd like to remove. Cannot be null.
|
||||||
*/
|
*/
|
||||||
public void releaseNetworkRequest(PendingIntent operation) {
|
public void releaseNetworkRequest(@NonNull PendingIntent operation) {
|
||||||
printStackTrace();
|
printStackTrace();
|
||||||
checkPendingIntentNotNull(operation);
|
checkPendingIntentNotNull(operation);
|
||||||
try {
|
try {
|
||||||
@@ -3428,7 +3442,8 @@ public class ConnectivityManager {
|
|||||||
* The callback is invoked on the default internal Handler.
|
* The callback is invoked on the default internal Handler.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
public void registerNetworkCallback(NetworkRequest request, NetworkCallback networkCallback) {
|
public void registerNetworkCallback(@NonNull NetworkRequest request,
|
||||||
|
@NonNull NetworkCallback networkCallback) {
|
||||||
registerNetworkCallback(request, networkCallback, getDefaultHandler());
|
registerNetworkCallback(request, networkCallback, getDefaultHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3443,8 +3458,8 @@ public class ConnectivityManager {
|
|||||||
* @param handler {@link Handler} to specify the thread upon which the callback will be invoked.
|
* @param handler {@link Handler} to specify the thread upon which the callback will be invoked.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
public void registerNetworkCallback(
|
public void registerNetworkCallback(@NonNull NetworkRequest request,
|
||||||
NetworkRequest request, NetworkCallback networkCallback, Handler handler) {
|
@NonNull NetworkCallback networkCallback, @NonNull Handler handler) {
|
||||||
CallbackHandler cbHandler = new CallbackHandler(handler);
|
CallbackHandler cbHandler = new CallbackHandler(handler);
|
||||||
NetworkCapabilities nc = request.networkCapabilities;
|
NetworkCapabilities nc = request.networkCapabilities;
|
||||||
sendRequestForNetwork(nc, networkCallback, 0, LISTEN, TYPE_NONE, cbHandler);
|
sendRequestForNetwork(nc, networkCallback, 0, LISTEN, TYPE_NONE, cbHandler);
|
||||||
@@ -3480,7 +3495,8 @@ public class ConnectivityManager {
|
|||||||
* comes from {@link PendingIntent#getBroadcast}. Cannot be null.
|
* comes from {@link PendingIntent#getBroadcast}. Cannot be null.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
public void registerNetworkCallback(NetworkRequest request, PendingIntent operation) {
|
public void registerNetworkCallback(@NonNull NetworkRequest request,
|
||||||
|
@NonNull PendingIntent operation) {
|
||||||
printStackTrace();
|
printStackTrace();
|
||||||
checkPendingIntentNotNull(operation);
|
checkPendingIntentNotNull(operation);
|
||||||
try {
|
try {
|
||||||
@@ -3502,7 +3518,7 @@ public class ConnectivityManager {
|
|||||||
* The callback is invoked on the default internal Handler.
|
* The callback is invoked on the default internal Handler.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
public void registerDefaultNetworkCallback(NetworkCallback networkCallback) {
|
public void registerDefaultNetworkCallback(@NonNull NetworkCallback networkCallback) {
|
||||||
registerDefaultNetworkCallback(networkCallback, getDefaultHandler());
|
registerDefaultNetworkCallback(networkCallback, getDefaultHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3516,7 +3532,8 @@ public class ConnectivityManager {
|
|||||||
* @param handler {@link Handler} to specify the thread upon which the callback will be invoked.
|
* @param handler {@link Handler} to specify the thread upon which the callback will be invoked.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
public void registerDefaultNetworkCallback(NetworkCallback networkCallback, Handler handler) {
|
public void registerDefaultNetworkCallback(@NonNull NetworkCallback networkCallback,
|
||||||
|
@NonNull Handler handler) {
|
||||||
// This works because if the NetworkCapabilities are null,
|
// This works because if the NetworkCapabilities are null,
|
||||||
// ConnectivityService takes them from the default request.
|
// ConnectivityService takes them from the default request.
|
||||||
//
|
//
|
||||||
@@ -3541,7 +3558,7 @@ public class ConnectivityManager {
|
|||||||
* @param network {@link Network} specifying which network you're interested.
|
* @param network {@link Network} specifying which network you're interested.
|
||||||
* @return {@code true} on success, {@code false} if the {@link Network} is no longer valid.
|
* @return {@code true} on success, {@code false} if the {@link Network} is no longer valid.
|
||||||
*/
|
*/
|
||||||
public boolean requestBandwidthUpdate(Network network) {
|
public boolean requestBandwidthUpdate(@NonNull Network network) {
|
||||||
try {
|
try {
|
||||||
return mService.requestBandwidthUpdate(network);
|
return mService.requestBandwidthUpdate(network);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -3562,7 +3579,7 @@ public class ConnectivityManager {
|
|||||||
*
|
*
|
||||||
* @param networkCallback The {@link NetworkCallback} used when making the request.
|
* @param networkCallback The {@link NetworkCallback} used when making the request.
|
||||||
*/
|
*/
|
||||||
public void unregisterNetworkCallback(NetworkCallback networkCallback) {
|
public void unregisterNetworkCallback(@NonNull NetworkCallback networkCallback) {
|
||||||
printStackTrace();
|
printStackTrace();
|
||||||
checkCallbackNotNull(networkCallback);
|
checkCallbackNotNull(networkCallback);
|
||||||
final List<NetworkRequest> reqs = new ArrayList<>();
|
final List<NetworkRequest> reqs = new ArrayList<>();
|
||||||
@@ -3601,7 +3618,7 @@ public class ConnectivityManager {
|
|||||||
* {@link #registerNetworkCallback(NetworkRequest, android.app.PendingIntent)}.
|
* {@link #registerNetworkCallback(NetworkRequest, android.app.PendingIntent)}.
|
||||||
* Cannot be null.
|
* Cannot be null.
|
||||||
*/
|
*/
|
||||||
public void unregisterNetworkCallback(PendingIntent operation) {
|
public void unregisterNetworkCallback(@NonNull PendingIntent operation) {
|
||||||
checkPendingIntentNotNull(operation);
|
checkPendingIntentNotNull(operation);
|
||||||
releaseNetworkRequest(operation);
|
releaseNetworkRequest(operation);
|
||||||
}
|
}
|
||||||
@@ -3723,7 +3740,7 @@ public class ConnectivityManager {
|
|||||||
* @return a bitwise OR of zero or more of the {@code MULTIPATH_PREFERENCE_*} constants.
|
* @return a bitwise OR of zero or more of the {@code MULTIPATH_PREFERENCE_*} constants.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
|
||||||
public @MultipathPreference int getMultipathPreference(Network network) {
|
public @MultipathPreference int getMultipathPreference(@Nullable Network network) {
|
||||||
try {
|
try {
|
||||||
return mService.getMultipathPreference(network);
|
return mService.getMultipathPreference(network);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -3761,7 +3778,7 @@ public class ConnectivityManager {
|
|||||||
* the current binding.
|
* the current binding.
|
||||||
* @return {@code true} on success, {@code false} if the {@link Network} is no longer valid.
|
* @return {@code true} on success, {@code false} if the {@link Network} is no longer valid.
|
||||||
*/
|
*/
|
||||||
public boolean bindProcessToNetwork(Network network) {
|
public boolean bindProcessToNetwork(@Nullable Network network) {
|
||||||
// Forcing callers to call through non-static function ensures ConnectivityManager
|
// Forcing callers to call through non-static function ensures ConnectivityManager
|
||||||
// instantiated.
|
// instantiated.
|
||||||
return setProcessDefaultNetwork(network);
|
return setProcessDefaultNetwork(network);
|
||||||
@@ -3789,7 +3806,7 @@ public class ConnectivityManager {
|
|||||||
* is a direct replacement.
|
* is a direct replacement.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static boolean setProcessDefaultNetwork(Network network) {
|
public static boolean setProcessDefaultNetwork(@Nullable Network network) {
|
||||||
int netId = (network == null) ? NETID_UNSET : network.netId;
|
int netId = (network == null) ? NETID_UNSET : network.netId;
|
||||||
if (netId == NetworkUtils.getBoundNetworkForProcess()) {
|
if (netId == NetworkUtils.getBoundNetworkForProcess()) {
|
||||||
return true;
|
return true;
|
||||||
@@ -3820,6 +3837,7 @@ public class ConnectivityManager {
|
|||||||
*
|
*
|
||||||
* @return {@code Network} to which this process is bound, or {@code null}.
|
* @return {@code Network} to which this process is bound, or {@code null}.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Network getBoundNetworkForProcess() {
|
public Network getBoundNetworkForProcess() {
|
||||||
// Forcing callers to call thru non-static function ensures ConnectivityManager
|
// Forcing callers to call thru non-static function ensures ConnectivityManager
|
||||||
// instantiated.
|
// instantiated.
|
||||||
@@ -3836,6 +3854,7 @@ public class ConnectivityManager {
|
|||||||
* {@code getBoundNetworkForProcess} is a direct replacement.
|
* {@code getBoundNetworkForProcess} is a direct replacement.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@Nullable
|
||||||
public static Network getProcessDefaultNetwork() {
|
public static Network getProcessDefaultNetwork() {
|
||||||
int netId = NetworkUtils.getBoundNetworkForProcess();
|
int netId = NetworkUtils.getBoundNetworkForProcess();
|
||||||
if (netId == NETID_UNSET) return null;
|
if (netId == NETID_UNSET) return null;
|
||||||
@@ -3962,6 +3981,7 @@ public class ConnectivityManager {
|
|||||||
*
|
*
|
||||||
* @return Hash of network watchlist config file. Null if config does not exist.
|
* @return Hash of network watchlist config file. Null if config does not exist.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public byte[] getNetworkWatchlistConfigHash() {
|
public byte[] getNetworkWatchlistConfigHash() {
|
||||||
try {
|
try {
|
||||||
return mService.getNetworkWatchlistConfigHash();
|
return mService.getNetworkWatchlistConfigHash();
|
||||||
@@ -3983,8 +4003,8 @@ public class ConnectivityManager {
|
|||||||
* (e.g., if it is associated with the calling VPN app's tunnel) or
|
* (e.g., if it is associated with the calling VPN app's tunnel) or
|
||||||
* {@link android.os.Process#INVALID_UID} if the connection is not found.
|
* {@link android.os.Process#INVALID_UID} if the connection is not found.
|
||||||
*/
|
*/
|
||||||
public int getConnectionOwnerUid(int protocol, InetSocketAddress local,
|
public int getConnectionOwnerUid(int protocol, @NonNull InetSocketAddress local,
|
||||||
InetSocketAddress remote) {
|
@NonNull InetSocketAddress remote) {
|
||||||
ConnectionInfo connectionInfo = new ConnectionInfo(protocol, local, remote);
|
ConnectionInfo connectionInfo = new ConnectionInfo(protocol, local, remote);
|
||||||
try {
|
try {
|
||||||
return mService.getConnectionOwnerUid(connectionInfo);
|
return mService.getConnectionOwnerUid(connectionInfo);
|
||||||
|
|||||||
Reference in New Issue
Block a user