Replace com.android.internal.util.Preconditions.checkNotNull with
java.util.Objects.requireNonNull Bug: 126528330 Test: Treehugger Exempt-From-Owner-Approval: Global refactoring. Change-Id: Idb1b6ba41af3b52f3376b1157259af3c30328c4e
This commit is contained in:
committed by
Tobias Thierer
parent
467942cf30
commit
d4e7dd113d
@@ -47,8 +47,6 @@ import static android.os.Process.INVALID_UID;
|
||||
import static android.system.OsConstants.IPPROTO_TCP;
|
||||
import static android.system.OsConstants.IPPROTO_UDP;
|
||||
|
||||
import static com.android.internal.util.Preconditions.checkNotNull;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.BroadcastOptions;
|
||||
@@ -904,7 +902,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
* @see IpConnectivityMetrics.Logger
|
||||
*/
|
||||
public IpConnectivityMetrics.Logger getMetricsLogger() {
|
||||
return checkNotNull(LocalServices.getService(IpConnectivityMetrics.Logger.class),
|
||||
return Objects.requireNonNull(LocalServices.getService(IpConnectivityMetrics.Logger.class),
|
||||
"no IpConnectivityMetrics service");
|
||||
}
|
||||
|
||||
@@ -933,7 +931,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
IDnsResolver dnsresolver, IpConnectivityLog logger, INetd netd, Dependencies deps) {
|
||||
if (DBG) log("ConnectivityService starting up");
|
||||
|
||||
mDeps = checkNotNull(deps, "missing Dependencies");
|
||||
mDeps = Objects.requireNonNull(deps, "missing Dependencies");
|
||||
mSystemProperties = mDeps.getSystemProperties();
|
||||
mNetIdManager = mDeps.makeNetIdManager();
|
||||
|
||||
@@ -962,14 +960,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
mLingerDelayMs = mSystemProperties.getInt(LINGER_DELAY_PROPERTY, DEFAULT_LINGER_DELAY_MS);
|
||||
|
||||
mContext = checkNotNull(context, "missing Context");
|
||||
mNMS = checkNotNull(netManager, "missing INetworkManagementService");
|
||||
mStatsService = checkNotNull(statsService, "missing INetworkStatsService");
|
||||
mPolicyManager = checkNotNull(policyManager, "missing INetworkPolicyManager");
|
||||
mPolicyManagerInternal = checkNotNull(
|
||||
mContext = Objects.requireNonNull(context, "missing Context");
|
||||
mNMS = Objects.requireNonNull(netManager, "missing INetworkManagementService");
|
||||
mStatsService = Objects.requireNonNull(statsService, "missing INetworkStatsService");
|
||||
mPolicyManager = Objects.requireNonNull(policyManager, "missing INetworkPolicyManager");
|
||||
mPolicyManagerInternal = Objects.requireNonNull(
|
||||
LocalServices.getService(NetworkPolicyManagerInternal.class),
|
||||
"missing NetworkPolicyManagerInternal");
|
||||
mDnsResolver = checkNotNull(dnsresolver, "missing IDnsResolver");
|
||||
mDnsResolver = Objects.requireNonNull(dnsresolver, "missing IDnsResolver");
|
||||
mProxyTracker = mDeps.makeProxyTracker(mContext, mHandler);
|
||||
|
||||
mNetd = netd;
|
||||
@@ -5195,7 +5193,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
@Override
|
||||
public NetworkRequest pendingRequestForNetwork(NetworkCapabilities networkCapabilities,
|
||||
PendingIntent operation) {
|
||||
checkNotNull(operation, "PendingIntent cannot be null.");
|
||||
Objects.requireNonNull(operation, "PendingIntent cannot be null.");
|
||||
networkCapabilities = new NetworkCapabilities(networkCapabilities);
|
||||
enforceNetworkRequestPermissions(networkCapabilities);
|
||||
enforceMeteredApnPolicy(networkCapabilities);
|
||||
@@ -5222,7 +5220,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
@Override
|
||||
public void releasePendingNetworkRequest(PendingIntent operation) {
|
||||
checkNotNull(operation, "PendingIntent cannot be null.");
|
||||
Objects.requireNonNull(operation, "PendingIntent cannot be null.");
|
||||
mHandler.sendMessage(mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT,
|
||||
getCallingUid(), 0, operation));
|
||||
}
|
||||
@@ -5280,7 +5278,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
@Override
|
||||
public void pendingListenForNetwork(NetworkCapabilities networkCapabilities,
|
||||
PendingIntent operation) {
|
||||
checkNotNull(operation, "PendingIntent cannot be null.");
|
||||
Objects.requireNonNull(operation, "PendingIntent cannot be null.");
|
||||
if (!hasWifiNetworkListenPermission(networkCapabilities)) {
|
||||
enforceAccessPermission();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.server;
|
||||
|
||||
import static com.android.internal.util.Preconditions.checkNotNull;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
@@ -55,6 +53,7 @@ import java.net.InterfaceAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/** @hide */
|
||||
@@ -82,9 +81,9 @@ class TestNetworkService extends ITestNetworkManager.Stub {
|
||||
mHandlerThread.start();
|
||||
mHandler = new Handler(mHandlerThread.getLooper());
|
||||
|
||||
mContext = checkNotNull(context, "missing Context");
|
||||
mNMS = checkNotNull(netManager, "missing INetworkManagementService");
|
||||
mNetd = checkNotNull(NetdService.getInstance(), "could not get netd instance");
|
||||
mContext = Objects.requireNonNull(context, "missing Context");
|
||||
mNMS = Objects.requireNonNull(netManager, "missing INetworkManagementService");
|
||||
mNetd = Objects.requireNonNull(NetdService.getInstance(), "could not get netd instance");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +95,7 @@ class TestNetworkService extends ITestNetworkManager.Stub {
|
||||
private TestNetworkInterface createInterface(boolean isTun, LinkAddress[] linkAddrs) {
|
||||
enforceTestNetworkPermissions(mContext);
|
||||
|
||||
checkNotNull(linkAddrs, "missing linkAddrs");
|
||||
Objects.requireNonNull(linkAddrs, "missing linkAddrs");
|
||||
|
||||
String ifacePrefix = isTun ? TEST_TUN_PREFIX : TEST_TAP_PREFIX;
|
||||
String iface = ifacePrefix + sTestTunIndex.getAndIncrement();
|
||||
@@ -233,8 +232,8 @@ class TestNetworkService extends ITestNetworkManager.Stub {
|
||||
int callingUid,
|
||||
@NonNull IBinder binder)
|
||||
throws RemoteException, SocketException {
|
||||
checkNotNull(looper, "missing Looper");
|
||||
checkNotNull(context, "missing Context");
|
||||
Objects.requireNonNull(looper, "missing Looper");
|
||||
Objects.requireNonNull(context, "missing Context");
|
||||
// iface and binder validity checked by caller
|
||||
|
||||
// Build network info with special testing type
|
||||
@@ -267,7 +266,7 @@ class TestNetworkService extends ITestNetworkManager.Stub {
|
||||
// Find the currently assigned addresses, and add them to LinkProperties
|
||||
boolean allowIPv4 = false, allowIPv6 = false;
|
||||
NetworkInterface netIntf = NetworkInterface.getByName(iface);
|
||||
checkNotNull(netIntf, "No such network interface found: " + netIntf);
|
||||
Objects.requireNonNull(netIntf, "No such network interface found: " + netIntf);
|
||||
|
||||
for (InterfaceAddress intfAddr : netIntf.getInterfaceAddresses()) {
|
||||
lp.addLinkAddress(
|
||||
@@ -305,8 +304,8 @@ class TestNetworkService extends ITestNetworkManager.Stub {
|
||||
@NonNull IBinder binder) {
|
||||
enforceTestNetworkPermissions(mContext);
|
||||
|
||||
checkNotNull(iface, "missing Iface");
|
||||
checkNotNull(binder, "missing IBinder");
|
||||
Objects.requireNonNull(iface, "missing Iface");
|
||||
Objects.requireNonNull(binder, "missing IBinder");
|
||||
|
||||
if (!(iface.startsWith(INetd.IPSEC_INTERFACE_PREFIX)
|
||||
|| iface.startsWith(TEST_TUN_PREFIX))) {
|
||||
|
||||
Reference in New Issue
Block a user