Merge "Replace com.android.internal.util.Preconditions.checkNotNull with java.util.Objects.requireNonNull" am: f8098ddadf

Change-Id: I9f9ba24036e19f568942466c866c7be23112c10a
This commit is contained in:
Daulet Zhanguzin
2020-03-27 12:07:53 +00:00
committed by Automerger Merge Worker
2 changed files with 10 additions and 11 deletions

View File

@@ -25,8 +25,6 @@ import static android.system.OsConstants.EINVAL;
import static android.system.OsConstants.IPPROTO_UDP; import static android.system.OsConstants.IPPROTO_UDP;
import static android.system.OsConstants.SOCK_DGRAM; import static android.system.OsConstants.SOCK_DGRAM;
import static com.android.internal.util.Preconditions.checkNotNull;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.app.AppOpsManager; import android.app.AppOpsManager;
import android.content.Context; import android.content.Context;
@@ -575,7 +573,7 @@ public class IpSecService extends IIpSecService.Stub {
} }
void put(int key, RefcountedResource<T> obj) { void put(int key, RefcountedResource<T> obj) {
checkNotNull(obj, "Null resources cannot be added"); Objects.requireNonNull(obj, "Null resources cannot be added");
mArray.put(key, obj); mArray.put(key, obj);
} }
@@ -1114,7 +1112,7 @@ public class IpSecService extends IIpSecService.Stub {
if (requestedSpi > 0 && requestedSpi < 256) { if (requestedSpi > 0 && requestedSpi < 256) {
throw new IllegalArgumentException("ESP SPI must not be in the range of 0-255."); throw new IllegalArgumentException("ESP SPI must not be in the range of 0-255.");
} }
checkNotNull(binder, "Null Binder passed to allocateSecurityParameterIndex"); Objects.requireNonNull(binder, "Null Binder passed to allocateSecurityParameterIndex");
int callingUid = Binder.getCallingUid(); int callingUid = Binder.getCallingUid();
UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid); UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid);
@@ -1231,7 +1229,7 @@ public class IpSecService extends IIpSecService.Stub {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Specified port number must be a valid non-reserved UDP port"); "Specified port number must be a valid non-reserved UDP port");
} }
checkNotNull(binder, "Null Binder passed to openUdpEncapsulationSocket"); Objects.requireNonNull(binder, "Null Binder passed to openUdpEncapsulationSocket");
int callingUid = Binder.getCallingUid(); int callingUid = Binder.getCallingUid();
UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid); UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid);
@@ -1291,8 +1289,8 @@ public class IpSecService extends IIpSecService.Stub {
String localAddr, String remoteAddr, Network underlyingNetwork, IBinder binder, String localAddr, String remoteAddr, Network underlyingNetwork, IBinder binder,
String callingPackage) { String callingPackage) {
enforceTunnelFeatureAndPermissions(callingPackage); enforceTunnelFeatureAndPermissions(callingPackage);
checkNotNull(binder, "Null Binder passed to createTunnelInterface"); Objects.requireNonNull(binder, "Null Binder passed to createTunnelInterface");
checkNotNull(underlyingNetwork, "No underlying network was specified"); Objects.requireNonNull(underlyingNetwork, "No underlying network was specified");
checkInetAddress(localAddr); checkInetAddress(localAddr);
checkInetAddress(remoteAddr); checkInetAddress(remoteAddr);
@@ -1573,7 +1571,7 @@ public class IpSecService extends IIpSecService.Stub {
"IPsec Tunnel Mode requires PackageManager.FEATURE_IPSEC_TUNNELS"); "IPsec Tunnel Mode requires PackageManager.FEATURE_IPSEC_TUNNELS");
} }
checkNotNull(callingPackage, "Null calling package cannot create IpSec tunnels"); Objects.requireNonNull(callingPackage, "Null calling package cannot create IpSec tunnels");
// OP_MANAGE_IPSEC_TUNNELS will return MODE_ERRORED by default, including for the system // OP_MANAGE_IPSEC_TUNNELS will return MODE_ERRORED by default, including for the system
// server. If the appop is not granted, require that the caller has the MANAGE_IPSEC_TUNNELS // server. If the appop is not granted, require that the caller has the MANAGE_IPSEC_TUNNELS
@@ -1642,12 +1640,12 @@ public class IpSecService extends IIpSecService.Stub {
@Override @Override
public synchronized IpSecTransformResponse createTransform( public synchronized IpSecTransformResponse createTransform(
IpSecConfig c, IBinder binder, String callingPackage) throws RemoteException { IpSecConfig c, IBinder binder, String callingPackage) throws RemoteException {
checkNotNull(c); Objects.requireNonNull(c);
if (c.getMode() == IpSecTransform.MODE_TUNNEL) { if (c.getMode() == IpSecTransform.MODE_TUNNEL) {
enforceTunnelFeatureAndPermissions(callingPackage); enforceTunnelFeatureAndPermissions(callingPackage);
} }
checkIpSecConfig(c); checkIpSecConfig(c);
checkNotNull(binder, "Null Binder passed to createTransform"); Objects.requireNonNull(binder, "Null Binder passed to createTransform");
final int resourceId = mNextResourceId++; final int resourceId = mNextResourceId++;
UserRecord userRecord = mUserResourceTracker.getUserRecord(Binder.getCallingUid()); UserRecord userRecord = mUserResourceTracker.getUserRecord(Binder.getCallingUid());

View File

@@ -46,6 +46,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Objects;
/** /**
* Generic connector class for interfacing with a native daemon which uses the * Generic connector class for interfacing with a native daemon which uses the
@@ -126,7 +127,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
*/ */
public void setWarnIfHeld(Object warnIfHeld) { public void setWarnIfHeld(Object warnIfHeld) {
Preconditions.checkState(mWarnIfHeld == null); Preconditions.checkState(mWarnIfHeld == null);
mWarnIfHeld = Preconditions.checkNotNull(warnIfHeld); mWarnIfHeld = Objects.requireNonNull(warnIfHeld);
} }
@Override @Override