Merge "Replace com.android.internal.util.Preconditions.checkNotNull with java.util.Objects.requireNonNull" am: edb04b0849 am: 5727033c3a am: 3a18f484a1
Change-Id: I54b4c3268878a10583dc6a4cf07f07588f0ca6cf
diff --git a/services/core/java/com/android/server/net/LockdownVpnTracker.java b/services/core/java/com/android/server/net/LockdownVpnTracker.java
index 4cb41da..ef8f647 100644
--- a/services/core/java/com/android/server/net/LockdownVpnTracker.java
+++ b/services/core/java/com/android/server/net/LockdownVpnTracker.java
@@ -45,12 +45,12 @@
import com.android.internal.net.VpnConfig;
import com.android.internal.net.VpnProfile;
import com.android.internal.notification.SystemNotificationChannels;
-import com.android.internal.util.Preconditions;
import com.android.server.ConnectivityService;
import com.android.server.EventLogTags;
import com.android.server.connectivity.Vpn;
import java.util.List;
+import java.util.Objects;
/**
* State tracker for lockdown mode. Watches for normal {@link NetworkInfo} to be
@@ -90,11 +90,11 @@
@NonNull Handler handler,
@NonNull Vpn vpn,
@NonNull VpnProfile profile) {
- mContext = Preconditions.checkNotNull(context);
- mConnService = Preconditions.checkNotNull(connService);
- mHandler = Preconditions.checkNotNull(handler);
- mVpn = Preconditions.checkNotNull(vpn);
- mProfile = Preconditions.checkNotNull(profile);
+ mContext = Objects.requireNonNull(context);
+ mConnService = Objects.requireNonNull(connService);
+ mHandler = Objects.requireNonNull(handler);
+ mVpn = Objects.requireNonNull(vpn);
+ mProfile = Objects.requireNonNull(profile);
final Intent configIntent = new Intent(ACTION_VPN_SETTINGS);
mConfigIntent = PendingIntent.getActivity(mContext, 0, configIntent, 0);
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 99562eb..0171e1f 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -91,7 +91,6 @@
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import static com.android.internal.util.ArrayUtils.appendInt;
-import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.internal.util.XmlUtils.readBooleanAttribute;
import static com.android.internal.util.XmlUtils.readIntAttribute;
import static com.android.internal.util.XmlUtils.readLongAttribute;
@@ -614,12 +613,12 @@
public NetworkPolicyManagerService(Context context, IActivityManager activityManager,
INetworkManagementService networkManagement, IPackageManager pm, Clock clock,
File systemDir, boolean suppressDefaultPolicy) {
- mContext = checkNotNull(context, "missing context");
- mActivityManager = checkNotNull(activityManager, "missing activityManager");
- mNetworkManager = checkNotNull(networkManagement, "missing networkManagement");
+ mContext = Objects.requireNonNull(context, "missing context");
+ mActivityManager = Objects.requireNonNull(activityManager, "missing activityManager");
+ mNetworkManager = Objects.requireNonNull(networkManagement, "missing networkManagement");
mDeviceIdleController = IDeviceIdleController.Stub.asInterface(ServiceManager.getService(
Context.DEVICE_IDLE_CONTROLLER));
- mClock = checkNotNull(clock, "missing Clock");
+ mClock = Objects.requireNonNull(clock, "missing Clock");
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
mIPm = pm;
@@ -646,7 +645,7 @@
}
public void bindConnectivityManager(IConnectivityManager connManager) {
- mConnManager = checkNotNull(connManager, "missing IConnectivityManager");
+ mConnManager = Objects.requireNonNull(connManager, "missing IConnectivityManager");
}
@GuardedBy("mUidRulesFirstLock")
@@ -3295,7 +3294,7 @@
enforceSubscriptionPlanValidity(plans);
for (SubscriptionPlan plan : plans) {
- Preconditions.checkNotNull(plan);
+ Objects.requireNonNull(plan);
}
final long token = Binder.clearCallingIdentity();
diff --git a/services/core/java/com/android/server/net/NetworkStatsRecorder.java b/services/core/java/com/android/server/net/NetworkStatsRecorder.java
index 6af962b..9eff5d1 100644
--- a/services/core/java/com/android/server/net/NetworkStatsRecorder.java
+++ b/services/core/java/com/android/server/net/NetworkStatsRecorder.java
@@ -21,8 +21,6 @@
import static android.net.TrafficStats.MB_IN_BYTES;
import static android.text.format.DateUtils.YEAR_IN_MILLIS;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import android.net.NetworkStats;
import android.net.NetworkStats.NonMonotonicObserver;
import android.net.NetworkStatsHistory;
@@ -54,6 +52,7 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
+import java.util.Objects;
/**
* Logic to record deltas between periodic {@link NetworkStats} snapshots into
@@ -116,9 +115,9 @@
*/
public NetworkStatsRecorder(FileRotator rotator, NonMonotonicObserver<String> observer,
DropBoxManager dropBox, String cookie, long bucketDuration, boolean onlyTags) {
- mRotator = checkNotNull(rotator, "missing FileRotator");
- mObserver = checkNotNull(observer, "missing NonMonotonicObserver");
- mDropBox = checkNotNull(dropBox, "missing DropBoxManager");
+ mRotator = Objects.requireNonNull(rotator, "missing FileRotator");
+ mObserver = Objects.requireNonNull(observer, "missing NonMonotonicObserver");
+ mDropBox = Objects.requireNonNull(dropBox, "missing DropBoxManager");
mCookie = cookie;
mBucketDuration = bucketDuration;
@@ -165,7 +164,7 @@
* as reference is valid.
*/
public NetworkStatsCollection getOrLoadCompleteLocked() {
- checkNotNull(mRotator, "missing FileRotator");
+ Objects.requireNonNull(mRotator, "missing FileRotator");
NetworkStatsCollection res = mComplete != null ? mComplete.get() : null;
if (res == null) {
res = loadLocked(Long.MIN_VALUE, Long.MAX_VALUE);
@@ -175,7 +174,7 @@
}
public NetworkStatsCollection getOrLoadPartialLocked(long start, long end) {
- checkNotNull(mRotator, "missing FileRotator");
+ Objects.requireNonNull(mRotator, "missing FileRotator");
NetworkStatsCollection res = mComplete != null ? mComplete.get() : null;
if (res == null) {
res = loadLocked(start, end);
@@ -280,7 +279,7 @@
* {@link #mPersistThresholdBytes}.
*/
public void maybePersistLocked(long currentTimeMillis) {
- checkNotNull(mRotator, "missing FileRotator");
+ Objects.requireNonNull(mRotator, "missing FileRotator");
final long pendingBytes = mPending.getTotalBytes();
if (pendingBytes >= mPersistThresholdBytes) {
forcePersistLocked(currentTimeMillis);
@@ -293,7 +292,7 @@
* Force persisting any pending deltas.
*/
public void forcePersistLocked(long currentTimeMillis) {
- checkNotNull(mRotator, "missing FileRotator");
+ Objects.requireNonNull(mRotator, "missing FileRotator");
if (mPending.isDirty()) {
if (LOGD) Slog.d(TAG, "forcePersistLocked() writing for " + mCookie);
try {
@@ -356,7 +355,7 @@
private final NetworkStatsCollection mCollection;
public CombiningRewriter(NetworkStatsCollection collection) {
- mCollection = checkNotNull(collection, "missing NetworkStatsCollection");
+ mCollection = Objects.requireNonNull(collection, "missing NetworkStatsCollection");
}
@Override
@@ -418,7 +417,7 @@
}
public void importLegacyNetworkLocked(File file) throws IOException {
- checkNotNull(mRotator, "missing FileRotator");
+ Objects.requireNonNull(mRotator, "missing FileRotator");
// legacy file still exists; start empty to avoid double importing
mRotator.deleteAll();
@@ -438,7 +437,7 @@
}
public void importLegacyUidLocked(File file) throws IOException {
- checkNotNull(mRotator, "missing FileRotator");
+ Objects.requireNonNull(mRotator, "missing FileRotator");
// legacy file still exists; start empty to avoid double importing
mRotator.deleteAll();
diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java
index 0288f0c..ec8a8e7 100644
--- a/services/core/java/com/android/server/net/NetworkStatsService.java
+++ b/services/core/java/com/android/server/net/NetworkStatsService.java
@@ -65,7 +65,6 @@
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
import static android.text.format.DateUtils.SECOND_IN_MILLIS;
-import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.server.NetworkManagementService.LIMIT_GLOBAL_ALERT;
import static com.android.server.NetworkManagementSocketTagger.resetKernelUidStats;
import static com.android.server.NetworkManagementSocketTagger.setKernelCounterSet;
@@ -148,6 +147,7 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
/**
* Collect and persist detailed network statistics, and provide this data to
@@ -357,17 +357,18 @@
TelephonyManager teleManager, NetworkStatsSettings settings,
NetworkStatsFactory factory, NetworkStatsObservers statsObservers, File systemDir,
File baseDir) {
- mContext = checkNotNull(context, "missing Context");
- mNetworkManager = checkNotNull(networkManager, "missing INetworkManagementService");
- mAlarmManager = checkNotNull(alarmManager, "missing AlarmManager");
- mClock = checkNotNull(clock, "missing Clock");
- mSettings = checkNotNull(settings, "missing NetworkStatsSettings");
- mTeleManager = checkNotNull(teleManager, "missing TelephonyManager");
- mWakeLock = checkNotNull(wakeLock, "missing WakeLock");
- mStatsFactory = checkNotNull(factory, "missing factory");
- mStatsObservers = checkNotNull(statsObservers, "missing NetworkStatsObservers");
- mSystemDir = checkNotNull(systemDir, "missing systemDir");
- mBaseDir = checkNotNull(baseDir, "missing baseDir");
+ mContext = Objects.requireNonNull(context, "missing Context");
+ mNetworkManager = Objects.requireNonNull(networkManager,
+ "missing INetworkManagementService");
+ mAlarmManager = Objects.requireNonNull(alarmManager, "missing AlarmManager");
+ mClock = Objects.requireNonNull(clock, "missing Clock");
+ mSettings = Objects.requireNonNull(settings, "missing NetworkStatsSettings");
+ mTeleManager = Objects.requireNonNull(teleManager, "missing TelephonyManager");
+ mWakeLock = Objects.requireNonNull(wakeLock, "missing WakeLock");
+ mStatsFactory = Objects.requireNonNull(factory, "missing factory");
+ mStatsObservers = Objects.requireNonNull(statsObservers, "missing NetworkStatsObservers");
+ mSystemDir = Objects.requireNonNull(systemDir, "missing systemDir");
+ mBaseDir = Objects.requireNonNull(baseDir, "missing baseDir");
mUseBpfTrafficStats = new File("/sys/fs/bpf/map_netd_app_uid_stats_map").exists();
}
@@ -896,11 +897,11 @@
@Override
public DataUsageRequest registerUsageCallback(String callingPackage,
DataUsageRequest request, Messenger messenger, IBinder binder) {
- checkNotNull(callingPackage, "calling package is null");
- checkNotNull(request, "DataUsageRequest is null");
- checkNotNull(request.template, "NetworkTemplate is null");
- checkNotNull(messenger, "messenger is null");
- checkNotNull(binder, "binder is null");
+ Objects.requireNonNull(callingPackage, "calling package is null");
+ Objects.requireNonNull(request, "DataUsageRequest is null");
+ Objects.requireNonNull(request.template, "NetworkTemplate is null");
+ Objects.requireNonNull(messenger, "messenger is null");
+ Objects.requireNonNull(binder, "binder is null");
int callingUid = Binder.getCallingUid();
@NetworkStatsAccess.Level int accessLevel = checkAccessLevel(callingPackage);
@@ -921,7 +922,7 @@
@Override
public void unregisterUsageRequest(DataUsageRequest request) {
- checkNotNull(request, "DataUsageRequest is null");
+ Objects.requireNonNull(request, "DataUsageRequest is null");
int callingUid = Binder.getCallingUid();
final long token = Binder.clearCallingIdentity();
@@ -1795,7 +1796,7 @@
private final ContentResolver mResolver;
public DefaultNetworkStatsSettings(Context context) {
- mResolver = checkNotNull(context.getContentResolver());
+ mResolver = Objects.requireNonNull(context.getContentResolver());
// TODO: adjust these timings for production builds
}