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
d55b2c8674
commit
c120601182
@@ -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;
|
||||||
@@ -76,6 +74,7 @@ import java.net.InetSocketAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A service to manage multiple clients that want to access the IpSec API. The service is
|
* A service to manage multiple clients that want to access the IpSec API. The service is
|
||||||
@@ -566,7 +565,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1101,7 +1100,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);
|
||||||
@@ -1218,7 +1217,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);
|
||||||
@@ -1278,8 +1277,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);
|
||||||
|
|
||||||
@@ -1556,7 +1555,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");
|
||||||
switch (getAppOpsManager().noteOp(TUNNEL_OP, Binder.getCallingUid(), callingPackage)) {
|
switch (getAppOpsManager().noteOp(TUNNEL_OP, Binder.getCallingUid(), callingPackage)) {
|
||||||
case AppOpsManager.MODE_DEFAULT:
|
case AppOpsManager.MODE_DEFAULT:
|
||||||
mContext.enforceCallingOrSelfPermission(
|
mContext.enforceCallingOrSelfPermission(
|
||||||
@@ -1625,12 +1624,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());
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user