Merge "Replace com.android.internal.util.Preconditions.checkNotNull with java.util.Objects.requireNonNull" am: f8098ddadf am: fd749ba37e
Change-Id: I024e79fc24b8962ff6bd10e4b7c7fc4ad13cbf27
This commit is contained in:
@@ -54,7 +54,6 @@ import com.android.internal.app.IAppOpsCallback;
|
||||
import com.android.internal.app.IAppOpsService;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.internal.util.StatLogger;
|
||||
import com.android.server.ForceAppStandbyTrackerProto.ExemptedPackage;
|
||||
import com.android.server.ForceAppStandbyTrackerProto.RunAnyInBackgroundRestrictedPackages;
|
||||
@@ -62,6 +61,7 @@ import com.android.server.ForceAppStandbyTrackerProto.RunAnyInBackgroundRestrict
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Class to keep track of the information related to "force app standby", which includes:
|
||||
@@ -416,12 +416,12 @@ public class AppStateTracker {
|
||||
}
|
||||
mStarted = true;
|
||||
|
||||
mIActivityManager = Preconditions.checkNotNull(injectIActivityManager());
|
||||
mActivityManagerInternal = Preconditions.checkNotNull(injectActivityManagerInternal());
|
||||
mAppOpsManager = Preconditions.checkNotNull(injectAppOpsManager());
|
||||
mAppOpsService = Preconditions.checkNotNull(injectIAppOpsService());
|
||||
mPowerManagerInternal = Preconditions.checkNotNull(injectPowerManagerInternal());
|
||||
mUsageStatsManagerInternal = Preconditions.checkNotNull(
|
||||
mIActivityManager = Objects.requireNonNull(injectIActivityManager());
|
||||
mActivityManagerInternal = Objects.requireNonNull(injectActivityManagerInternal());
|
||||
mAppOpsManager = Objects.requireNonNull(injectAppOpsManager());
|
||||
mAppOpsService = Objects.requireNonNull(injectIAppOpsService());
|
||||
mPowerManagerInternal = Objects.requireNonNull(injectPowerManagerInternal());
|
||||
mUsageStatsManagerInternal = Objects.requireNonNull(
|
||||
injectUsageStatsManagerInternal());
|
||||
|
||||
mFlagsObserver = new FeatureFlagsObserver();
|
||||
|
||||
@@ -49,8 +49,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 static java.util.Map.Entry;
|
||||
|
||||
import android.Manifest;
|
||||
@@ -929,7 +927,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");
|
||||
}
|
||||
|
||||
@@ -958,10 +956,10 @@ 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();
|
||||
mContext = checkNotNull(context, "missing Context");
|
||||
mContext = Objects.requireNonNull(context, "missing Context");
|
||||
|
||||
mMetricsLog = logger;
|
||||
mDefaultRequest = createDefaultInternetRequestForTransport(-1, NetworkRequest.Type.REQUEST);
|
||||
@@ -991,13 +989,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
mLingerDelayMs = mSystemProperties.getInt(LINGER_DELAY_PROPERTY, DEFAULT_LINGER_DELAY_MS);
|
||||
|
||||
mNMS = checkNotNull(netManager, "missing INetworkManagementService");
|
||||
mStatsService = checkNotNull(statsService, "missing INetworkStatsService");
|
||||
mPolicyManager = checkNotNull(policyManager, "missing INetworkPolicyManager");
|
||||
mPolicyManagerInternal = checkNotNull(
|
||||
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;
|
||||
@@ -5508,7 +5506,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
@Override
|
||||
public NetworkRequest pendingRequestForNetwork(NetworkCapabilities networkCapabilities,
|
||||
PendingIntent operation, @NonNull String callingPackageName) {
|
||||
checkNotNull(operation, "PendingIntent cannot be null.");
|
||||
Objects.requireNonNull(operation, "PendingIntent cannot be null.");
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
networkCapabilities = new NetworkCapabilities(networkCapabilities);
|
||||
enforceNetworkRequestPermissions(networkCapabilities);
|
||||
@@ -5537,7 +5535,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));
|
||||
}
|
||||
@@ -5596,7 +5594,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
@Override
|
||||
public void pendingListenForNetwork(NetworkCapabilities networkCapabilities,
|
||||
PendingIntent operation, @NonNull String callingPackageName) {
|
||||
checkNotNull(operation, "PendingIntent cannot be null.");
|
||||
Objects.requireNonNull(operation, "PendingIntent cannot be null.");
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
if (!hasWifiNetworkListenPermission(networkCapabilities)) {
|
||||
enforceAccessPermission();
|
||||
|
||||
@@ -47,6 +47,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -113,9 +114,9 @@ class ExplicitHealthCheckController {
|
||||
Slog.wtf(TAG, "Resetting health check controller callbacks");
|
||||
}
|
||||
|
||||
mPassedConsumer = Preconditions.checkNotNull(passedConsumer);
|
||||
mSupportedConsumer = Preconditions.checkNotNull(supportedConsumer);
|
||||
mNotifySyncRunnable = Preconditions.checkNotNull(notifySyncRunnable);
|
||||
mPassedConsumer = Objects.requireNonNull(passedConsumer);
|
||||
mSupportedConsumer = Objects.requireNonNull(supportedConsumer);
|
||||
mNotifySyncRunnable = Objects.requireNonNull(notifySyncRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@ import static android.system.OsConstants.EINVAL;
|
||||
import static android.system.OsConstants.IPPROTO_UDP;
|
||||
import static android.system.OsConstants.SOCK_DGRAM;
|
||||
|
||||
import static com.android.internal.util.Preconditions.checkNotNull;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
@@ -575,7 +573,7 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1114,7 +1112,7 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
if (requestedSpi > 0 && requestedSpi < 256) {
|
||||
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();
|
||||
UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid);
|
||||
@@ -1231,7 +1229,7 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
throw new IllegalArgumentException(
|
||||
"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();
|
||||
UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid);
|
||||
@@ -1291,8 +1289,8 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
String localAddr, String remoteAddr, Network underlyingNetwork, IBinder binder,
|
||||
String callingPackage) {
|
||||
enforceTunnelFeatureAndPermissions(callingPackage);
|
||||
checkNotNull(binder, "Null Binder passed to createTunnelInterface");
|
||||
checkNotNull(underlyingNetwork, "No underlying network was specified");
|
||||
Objects.requireNonNull(binder, "Null Binder passed to createTunnelInterface");
|
||||
Objects.requireNonNull(underlyingNetwork, "No underlying network was specified");
|
||||
checkInetAddress(localAddr);
|
||||
checkInetAddress(remoteAddr);
|
||||
|
||||
@@ -1573,7 +1571,7 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
"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
|
||||
// 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
|
||||
public synchronized IpSecTransformResponse createTransform(
|
||||
IpSecConfig c, IBinder binder, String callingPackage) throws RemoteException {
|
||||
checkNotNull(c);
|
||||
Objects.requireNonNull(c);
|
||||
if (c.getMode() == IpSecTransform.MODE_TUNNEL) {
|
||||
enforceTunnelFeatureAndPermissions(callingPackage);
|
||||
}
|
||||
checkIpSecConfig(c);
|
||||
checkNotNull(binder, "Null Binder passed to createTransform");
|
||||
Objects.requireNonNull(binder, "Null Binder passed to createTransform");
|
||||
final int resourceId = mNextResourceId++;
|
||||
|
||||
UserRecord userRecord = mUserResourceTracker.getUserRecord(Binder.getCallingUid());
|
||||
|
||||
@@ -25,7 +25,6 @@ import static android.location.LocationProvider.AVAILABLE;
|
||||
import static android.os.PowerManager.locationPowerSaveModeToString;
|
||||
import static android.provider.Settings.Global.LOCATION_DISABLE_STATUS_CALLBACKS;
|
||||
|
||||
import static com.android.internal.util.Preconditions.checkNotNull;
|
||||
import static com.android.internal.util.Preconditions.checkState;
|
||||
|
||||
import android.Manifest;
|
||||
@@ -133,6 +132,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
@@ -986,7 +986,7 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
|
||||
@GuardedBy("mLock")
|
||||
public void attachLocked(AbstractLocationProvider provider) {
|
||||
checkNotNull(provider);
|
||||
Objects.requireNonNull(provider);
|
||||
checkState(mProvider == null);
|
||||
|
||||
if (D) {
|
||||
|
||||
@@ -46,6 +46,7 @@ import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
Preconditions.checkState(mWarnIfHeld == null);
|
||||
mWarnIfHeld = Preconditions.checkNotNull(warnIfHeld);
|
||||
mWarnIfHeld = Objects.requireNonNull(warnIfHeld);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -111,6 +111,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
@@ -458,7 +459,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
|
||||
@Override
|
||||
public void registerTetheringStatsProvider(ITetheringStatsProvider provider, String name) {
|
||||
NetworkStack.checkNetworkStackPermission(mContext);
|
||||
Preconditions.checkNotNull(provider);
|
||||
Objects.requireNonNull(provider);
|
||||
synchronized(mTetheringStatsProviders) {
|
||||
mTetheringStatsProviders.put(provider, name);
|
||||
}
|
||||
|
||||
@@ -1934,7 +1934,7 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
public void setVolumeNickname(String fsUuid, String nickname) {
|
||||
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
|
||||
|
||||
Preconditions.checkNotNull(fsUuid);
|
||||
Objects.requireNonNull(fsUuid);
|
||||
synchronized (mLock) {
|
||||
final VolumeRecord rec = mRecords.get(fsUuid);
|
||||
rec.nickname = nickname;
|
||||
@@ -1947,7 +1947,7 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
public void setVolumeUserFlags(String fsUuid, int flags, int mask) {
|
||||
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
|
||||
|
||||
Preconditions.checkNotNull(fsUuid);
|
||||
Objects.requireNonNull(fsUuid);
|
||||
synchronized (mLock) {
|
||||
final VolumeRecord rec = mRecords.get(fsUuid);
|
||||
rec.userFlags = (rec.userFlags & ~mask) | (flags & mask);
|
||||
@@ -1960,7 +1960,7 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
public void forgetVolume(String fsUuid) {
|
||||
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
|
||||
|
||||
Preconditions.checkNotNull(fsUuid);
|
||||
Objects.requireNonNull(fsUuid);
|
||||
|
||||
synchronized (mLock) {
|
||||
final VolumeRecord rec = mRecords.remove(fsUuid);
|
||||
@@ -2361,7 +2361,7 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
|
||||
@Override
|
||||
public String getMountedObbPath(String rawPath) {
|
||||
Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
|
||||
Objects.requireNonNull(rawPath, "rawPath cannot be null");
|
||||
|
||||
warnOnNotMounted();
|
||||
|
||||
@@ -2379,7 +2379,7 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
|
||||
@Override
|
||||
public boolean isObbMounted(String rawPath) {
|
||||
Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
|
||||
Objects.requireNonNull(rawPath, "rawPath cannot be null");
|
||||
synchronized (mObbMounts) {
|
||||
return mObbPathToStateMap.containsKey(rawPath);
|
||||
}
|
||||
@@ -2388,10 +2388,10 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
@Override
|
||||
public void mountObb(String rawPath, String canonicalPath, String key,
|
||||
IObbActionListener token, int nonce, ObbInfo obbInfo) {
|
||||
Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
|
||||
Preconditions.checkNotNull(canonicalPath, "canonicalPath cannot be null");
|
||||
Preconditions.checkNotNull(token, "token cannot be null");
|
||||
Preconditions.checkNotNull(obbInfo, "obbIfno cannot be null");
|
||||
Objects.requireNonNull(rawPath, "rawPath cannot be null");
|
||||
Objects.requireNonNull(canonicalPath, "canonicalPath cannot be null");
|
||||
Objects.requireNonNull(token, "token cannot be null");
|
||||
Objects.requireNonNull(obbInfo, "obbIfno cannot be null");
|
||||
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
final ObbState obbState = new ObbState(rawPath, canonicalPath,
|
||||
@@ -2405,7 +2405,7 @@ class StorageManagerService extends IStorageManager.Stub
|
||||
|
||||
@Override
|
||||
public void unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce) {
|
||||
Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
|
||||
Objects.requireNonNull(rawPath, "rawPath cannot be null");
|
||||
|
||||
final ObbState existingState;
|
||||
synchronized (mObbMounts) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.android.server.am.ActivityManagerService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
Reference in New Issue
Block a user