Merge "Replace com.android.internal.util.Preconditions.checkNotNull with java.util.Objects.requireNonNull"
diff --git a/Android.bp b/Android.bp
index 4b82e1d..e1f5abd9 100644
--- a/Android.bp
+++ b/Android.bp
@@ -284,6 +284,7 @@
name: "framework-aidl-export-defaults",
aidl: {
export_include_dirs: [
+ "apex/media/java",
"core/java",
"drm/java",
"graphics/java",
@@ -291,7 +292,6 @@
"location/java",
"lowpan/java",
"media/java",
- "media/apex/java",
"media/mca/effect/java",
"media/mca/filterfw/java",
"media/mca/filterpacks/java",
diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
index 1ec96ec..9310762 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
@@ -81,7 +81,6 @@
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.IndentingPrintWriter;
-import com.android.internal.util.Preconditions;
import com.android.server.AppStateTracker;
import com.android.server.DeviceIdleInternal;
import com.android.server.FgThread;
@@ -117,6 +116,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -1283,7 +1283,7 @@
super(context);
mLocalPM = LocalServices.getService(PackageManagerInternal.class);
- mActivityManagerInternal = Preconditions.checkNotNull(
+ mActivityManagerInternal = Objects.requireNonNull(
LocalServices.getService(ActivityManagerInternal.class));
mHandler = new JobHandler(context.getMainLooper());
@@ -1389,7 +1389,7 @@
controller.onSystemServicesReady();
}
- mAppStateTracker = Preconditions.checkNotNull(
+ mAppStateTracker = Objects.requireNonNull(
LocalServices.getService(AppStateTracker.class));
// Register br for package removals and user removals.
diff --git a/apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java b/apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java
index 8b61006..aa3d74a 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java
@@ -23,7 +23,6 @@
import android.util.proto.ProtoOutputStream;
import com.android.internal.util.IndentingPrintWriter;
-import com.android.internal.util.Preconditions;
import com.android.server.AppStateTracker;
import com.android.server.AppStateTracker.Listener;
import com.android.server.LocalServices;
@@ -32,6 +31,7 @@
import com.android.server.job.StateControllerProto;
import com.android.server.job.StateControllerProto.BackgroundJobsController.TrackedJob;
+import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -59,7 +59,7 @@
public BackgroundJobsController(JobSchedulerService service) {
super(service);
- mAppStateTracker = Preconditions.checkNotNull(
+ mAppStateTracker = Objects.requireNonNull(
LocalServices.getService(AppStateTracker.class));
mAppStateTracker.addListener(mForceAppStandbyListener);
}
diff --git a/apex/media/Android.bp b/apex/media/Android.bp
new file mode 100644
index 0000000..6bd0086
--- /dev/null
+++ b/apex/media/Android.bp
@@ -0,0 +1,120 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+java_library {
+ name: "updatable-media",
+
+ srcs: [
+ ":updatable-media-srcs",
+ ],
+
+ aidl: {
+ export_include_dirs: [
+ "java",
+ ],
+
+ // It would be great if we don't need to add include_dirs for public
+ // parcelable classes. Find a better way.
+ include_dirs: [
+ // To refer:
+ // android.os.Bundle
+ // android.os.ResultReceiver
+ "frameworks/base/core/java",
+ ],
+ },
+
+ permitted_packages: [
+ "android.media",
+ ],
+
+ installable: true,
+
+ // TODO: build against stable API surface. Use core_platform for now to avoid
+ // link-check failure with exoplayer building against "current".
+ sdk_version: "core_platform",
+ libs: [
+ // The order matters. android_system_* library should come later.
+ "framework_media_annotation",
+ "android_system_stubs_current",
+ ],
+
+ static_libs: [
+ "exoplayer2-core"
+ ],
+ jarjar_rules: "jarjar_rules.txt",
+
+ plugins: ["java_api_finder"],
+}
+
+filegroup {
+ name: "updatable-media-srcs",
+ srcs: [
+ ":mediaparser-srcs",
+ ":mediasession2-srcs",
+ ],
+}
+
+filegroup {
+ name: "mediasession2-srcs",
+ srcs: [
+ "java/android/media/Controller2Link.java",
+ "java/android/media/IMediaController2.aidl",
+ "java/android/media/IMediaSession2.aidl",
+ "java/android/media/IMediaSession2Service.aidl",
+ "java/android/media/MediaConstants.java",
+ "java/android/media/MediaController2.java",
+ "java/android/media/MediaSession2.java",
+ "java/android/media/MediaSession2Service.java",
+ "java/android/media/Session2Command.java",
+ "java/android/media/Session2CommandGroup.java",
+ "java/android/media/Session2Link.java",
+ "java/android/media/Session2Token.java",
+ ],
+ path: "java",
+}
+
+filegroup {
+ name: "mediaparser-srcs",
+ srcs: [
+ "java/android/media/MediaParser.java"
+ ],
+ path: "java"
+}
+
+droidstubs {
+ name: "updatable-media-stubs",
+ srcs: [
+ ":updatable-media-srcs",
+ ":framework-media-annotation-srcs",
+ ],
+ defaults: [ "framework-module-stubs-defaults-systemapi" ],
+ aidl: {
+ // TODO(b/135922046) remove this
+ include_dirs: ["frameworks/base/core/java"],
+ },
+ sdk_version: "system_current",
+}
+
+java_library {
+ name: "updatable_media_stubs",
+ srcs: [":updatable-media-stubs"],
+ sdk_version: "system_current",
+}
+
+java_library {
+ name: "framework_media_annotation",
+ srcs: [":framework-media-annotation-srcs"],
+ installable: false,
+ sdk_version: "core_current",
+}
diff --git a/apex/media/OWNERS b/apex/media/OWNERS
new file mode 100644
index 0000000..0ac750c
--- /dev/null
+++ b/apex/media/OWNERS
@@ -0,0 +1,4 @@
+andrewlewis@google.com
+dwkang@google.com
+marcone@google.com
+sungsoo@google.com
diff --git a/media/jarjar_rules.txt b/apex/media/jarjar_rules.txt
similarity index 100%
rename from media/jarjar_rules.txt
rename to apex/media/jarjar_rules.txt
diff --git a/media/apex/java/android/media/BufferingParams.java b/apex/media/java/android/media/BufferingParams.java
similarity index 97%
rename from media/apex/java/android/media/BufferingParams.java
rename to apex/media/java/android/media/BufferingParams.java
index 943f142..04af028 100644
--- a/media/apex/java/android/media/BufferingParams.java
+++ b/apex/media/java/android/media/BufferingParams.java
@@ -16,13 +16,9 @@
package android.media;
-import android.annotation.IntDef;
import android.os.Parcel;
import android.os.Parcelable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
/**
* Structure for source buffering management params.
*
diff --git a/media/apex/java/android/media/Controller2Link.aidl b/apex/media/java/android/media/Controller2Link.aidl
similarity index 100%
rename from media/apex/java/android/media/Controller2Link.aidl
rename to apex/media/java/android/media/Controller2Link.aidl
diff --git a/media/apex/java/android/media/Controller2Link.java b/apex/media/java/android/media/Controller2Link.java
similarity index 100%
rename from media/apex/java/android/media/Controller2Link.java
rename to apex/media/java/android/media/Controller2Link.java
diff --git a/media/apex/java/android/media/DataSourceCallback.java b/apex/media/java/android/media/DataSourceCallback.java
similarity index 100%
rename from media/apex/java/android/media/DataSourceCallback.java
rename to apex/media/java/android/media/DataSourceCallback.java
diff --git a/media/apex/java/android/media/IMediaController2.aidl b/apex/media/java/android/media/IMediaController2.aidl
similarity index 100%
rename from media/apex/java/android/media/IMediaController2.aidl
rename to apex/media/java/android/media/IMediaController2.aidl
diff --git a/media/apex/java/android/media/IMediaSession2.aidl b/apex/media/java/android/media/IMediaSession2.aidl
similarity index 100%
rename from media/apex/java/android/media/IMediaSession2.aidl
rename to apex/media/java/android/media/IMediaSession2.aidl
diff --git a/media/apex/java/android/media/IMediaSession2Service.aidl b/apex/media/java/android/media/IMediaSession2Service.aidl
similarity index 100%
rename from media/apex/java/android/media/IMediaSession2Service.aidl
rename to apex/media/java/android/media/IMediaSession2Service.aidl
diff --git a/media/apex/java/android/media/MediaConstants.java b/apex/media/java/android/media/MediaConstants.java
similarity index 100%
rename from media/apex/java/android/media/MediaConstants.java
rename to apex/media/java/android/media/MediaConstants.java
diff --git a/media/apex/java/android/media/MediaController2.java b/apex/media/java/android/media/MediaController2.java
similarity index 100%
rename from media/apex/java/android/media/MediaController2.java
rename to apex/media/java/android/media/MediaController2.java
diff --git a/media/apex/java/android/media/MediaParser.java b/apex/media/java/android/media/MediaParser.java
similarity index 100%
rename from media/apex/java/android/media/MediaParser.java
rename to apex/media/java/android/media/MediaParser.java
diff --git a/media/apex/java/android/media/MediaSession2.java b/apex/media/java/android/media/MediaSession2.java
similarity index 100%
rename from media/apex/java/android/media/MediaSession2.java
rename to apex/media/java/android/media/MediaSession2.java
diff --git a/media/apex/java/android/media/MediaSession2Service.java b/apex/media/java/android/media/MediaSession2Service.java
similarity index 100%
rename from media/apex/java/android/media/MediaSession2Service.java
rename to apex/media/java/android/media/MediaSession2Service.java
diff --git a/media/apex/java/android/media/ProxyDataSourceCallback.java b/apex/media/java/android/media/ProxyDataSourceCallback.java
similarity index 100%
rename from media/apex/java/android/media/ProxyDataSourceCallback.java
rename to apex/media/java/android/media/ProxyDataSourceCallback.java
diff --git a/media/apex/java/android/media/RoutingDelegate.java b/apex/media/java/android/media/RoutingDelegate.java
similarity index 100%
rename from media/apex/java/android/media/RoutingDelegate.java
rename to apex/media/java/android/media/RoutingDelegate.java
diff --git a/media/apex/java/android/media/Session2Command.aidl b/apex/media/java/android/media/Session2Command.aidl
similarity index 100%
rename from media/apex/java/android/media/Session2Command.aidl
rename to apex/media/java/android/media/Session2Command.aidl
diff --git a/media/apex/java/android/media/Session2Command.java b/apex/media/java/android/media/Session2Command.java
similarity index 100%
rename from media/apex/java/android/media/Session2Command.java
rename to apex/media/java/android/media/Session2Command.java
diff --git a/media/apex/java/android/media/Session2CommandGroup.java b/apex/media/java/android/media/Session2CommandGroup.java
similarity index 98%
rename from media/apex/java/android/media/Session2CommandGroup.java
rename to apex/media/java/android/media/Session2CommandGroup.java
index 0ee5f62..13aabfc 100644
--- a/media/apex/java/android/media/Session2CommandGroup.java
+++ b/apex/media/java/android/media/Session2CommandGroup.java
@@ -38,8 +38,8 @@
public final class Session2CommandGroup implements Parcelable {
private static final String TAG = "Session2CommandGroup";
- public static final @android.annotation.NonNull Parcelable.Creator<Session2CommandGroup> CREATOR =
- new Parcelable.Creator<Session2CommandGroup>() {
+ public static final @android.annotation.NonNull Parcelable.Creator<Session2CommandGroup>
+ CREATOR = new Parcelable.Creator<Session2CommandGroup>() {
@Override
public Session2CommandGroup createFromParcel(Parcel in) {
return new Session2CommandGroup(in);
diff --git a/media/apex/java/android/media/Session2Link.java b/apex/media/java/android/media/Session2Link.java
similarity index 100%
rename from media/apex/java/android/media/Session2Link.java
rename to apex/media/java/android/media/Session2Link.java
diff --git a/media/apex/java/android/media/Session2Token.aidl b/apex/media/java/android/media/Session2Token.aidl
similarity index 100%
rename from media/apex/java/android/media/Session2Token.aidl
rename to apex/media/java/android/media/Session2Token.aidl
diff --git a/media/apex/java/android/media/Session2Token.java b/apex/media/java/android/media/Session2Token.java
similarity index 95%
rename from media/apex/java/android/media/Session2Token.java
rename to apex/media/java/android/media/Session2Token.java
index 6eb76b1..aae2e1b 100644
--- a/media/apex/java/android/media/Session2Token.java
+++ b/apex/media/java/android/media/Session2Token.java
@@ -52,17 +52,18 @@
public final class Session2Token implements Parcelable {
private static final String TAG = "Session2Token";
- public static final @android.annotation.NonNull Creator<Session2Token> CREATOR = new Creator<Session2Token>() {
- @Override
- public Session2Token createFromParcel(Parcel p) {
- return new Session2Token(p);
- }
+ public static final @android.annotation.NonNull Creator<Session2Token> CREATOR =
+ new Creator<Session2Token>() {
+ @Override
+ public Session2Token createFromParcel(Parcel p) {
+ return new Session2Token(p);
+ }
- @Override
- public Session2Token[] newArray(int size) {
- return new Session2Token[size];
- }
- };
+ @Override
+ public Session2Token[] newArray(int size) {
+ return new Session2Token[size];
+ }
+ };
/**
* @hide
diff --git a/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java b/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java
index 7ed51ca..e4f7300 100644
--- a/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java
+++ b/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java
@@ -23,7 +23,6 @@
import static android.os.storage.VolumeInfo.TYPE_PRIVATE;
import static android.os.storage.VolumeInfo.TYPE_PUBLIC;
-import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem;
import static com.android.server.stats.IonMemoryUtil.readProcessSystemIonHeapSizesFromDebugfs;
import static com.android.server.stats.IonMemoryUtil.readSystemIonHeapSizeFromDebugfs;
@@ -1848,7 +1847,7 @@
int tagId, long elapsedNanos, long wallClockNanos,
List<StatsLogEventWrapper> pulledData) {
PowerProfile powerProfile = new PowerProfile(mContext);
- checkNotNull(powerProfile);
+ Objects.requireNonNull(powerProfile);
StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos,
wallClockNanos);
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 08f8734..a4f6f57 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -3659,7 +3659,7 @@
r.activity, Looper.myLooper());
}
r.activity.onGetDirectActions(cancellationSignal, (actions) -> {
- Preconditions.checkNotNull(actions);
+ Objects.requireNonNull(actions);
Preconditions.checkCollectionElementsNotNull(actions, "actions");
if (!actions.isEmpty()) {
final int actionCount = actions.size();
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 86a5c76..4840963 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -5517,8 +5517,8 @@
@RequiresPermission(android.Manifest.permission.GET_APP_OPS_STATS)
public void getHistoricalOps(@NonNull HistoricalOpsRequest request,
@NonNull Executor executor, @NonNull Consumer<HistoricalOps> callback) {
- Preconditions.checkNotNull(executor, "executor cannot be null");
- Preconditions.checkNotNull(callback, "callback cannot be null");
+ Objects.requireNonNull(executor, "executor cannot be null");
+ Objects.requireNonNull(callback, "callback cannot be null");
try {
mService.getHistoricalOps(request.mUid, request.mPackageName, request.mOpNames,
request.mBeginTimeMillis, request.mEndTimeMillis, request.mFlags,
@@ -5556,8 +5556,8 @@
@RequiresPermission(Manifest.permission.MANAGE_APPOPS)
public void getHistoricalOpsFromDiskRaw(@NonNull HistoricalOpsRequest request,
@Nullable Executor executor, @NonNull Consumer<HistoricalOps> callback) {
- Preconditions.checkNotNull(executor, "executor cannot be null");
- Preconditions.checkNotNull(callback, "callback cannot be null");
+ Objects.requireNonNull(executor, "executor cannot be null");
+ Objects.requireNonNull(callback, "callback cannot be null");
try {
mService.getHistoricalOpsFromDiskRaw(request.mUid, request.mPackageName,
request.mOpNames, request.mBeginTimeMillis, request.mEndTimeMillis,
@@ -7062,7 +7062,7 @@
private final IAppOpsAsyncNotedCallback mAsyncCb = new IAppOpsAsyncNotedCallback.Stub() {
@Override
public void opNoted(AsyncNotedAppOp op) {
- Preconditions.checkNotNull(op);
+ Objects.requireNonNull(op);
getAsyncNotedExecutor().execute(() -> onAsyncNoted(op));
}
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 7f26565..1c6a561 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -100,7 +100,6 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.SomeArgs;
-import com.android.internal.util.Preconditions;
import com.android.internal.util.UserIcons;
import dalvik.system.VMRuntime;
@@ -2149,7 +2148,7 @@
} else if (vol.isPrimaryPhysical()) {
volumeUuid = StorageManager.UUID_PRIMARY_PHYSICAL;
} else {
- volumeUuid = Preconditions.checkNotNull(vol.fsUuid);
+ volumeUuid = Objects.requireNonNull(vol.fsUuid);
}
return mPM.movePackage(packageName, volumeUuid);
@@ -2259,7 +2258,7 @@
} else if (vol.isPrimaryPhysical()) {
volumeUuid = StorageManager.UUID_PRIMARY_PHYSICAL;
} else {
- volumeUuid = Preconditions.checkNotNull(vol.fsUuid);
+ volumeUuid = Objects.requireNonNull(vol.fsUuid);
}
return mPM.movePrimaryStorage(volumeUuid);
@@ -2661,8 +2660,8 @@
/** @hide */
@Override
public KeySet getKeySetByAlias(String packageName, String alias) {
- Preconditions.checkNotNull(packageName);
- Preconditions.checkNotNull(alias);
+ Objects.requireNonNull(packageName);
+ Objects.requireNonNull(alias);
try {
return mPM.getKeySetByAlias(packageName, alias);
} catch (RemoteException e) {
@@ -2673,7 +2672,7 @@
/** @hide */
@Override
public KeySet getSigningKeySet(String packageName) {
- Preconditions.checkNotNull(packageName);
+ Objects.requireNonNull(packageName);
try {
return mPM.getSigningKeySet(packageName);
} catch (RemoteException e) {
@@ -2684,8 +2683,8 @@
/** @hide */
@Override
public boolean isSignedBy(String packageName, KeySet ks) {
- Preconditions.checkNotNull(packageName);
- Preconditions.checkNotNull(ks);
+ Objects.requireNonNull(packageName);
+ Objects.requireNonNull(ks);
try {
return mPM.isPackageSignedByKeySet(packageName, ks);
} catch (RemoteException e) {
@@ -2696,8 +2695,8 @@
/** @hide */
@Override
public boolean isSignedByExactly(String packageName, KeySet ks) {
- Preconditions.checkNotNull(packageName);
- Preconditions.checkNotNull(ks);
+ Objects.requireNonNull(packageName);
+ Objects.requireNonNull(ks);
try {
return mPM.isPackageSignedByKeySetExactly(packageName, ks);
} catch (RemoteException e) {
diff --git a/core/java/android/app/AuthenticationRequiredException.java b/core/java/android/app/AuthenticationRequiredException.java
index 0d87336..847d2c4 100644
--- a/core/java/android/app/AuthenticationRequiredException.java
+++ b/core/java/android/app/AuthenticationRequiredException.java
@@ -21,7 +21,7 @@
import android.os.Parcel;
import android.os.Parcelable;
-import com.android.internal.util.Preconditions;
+import java.util.Objects;
/**
* Specialization of {@link SecurityException} that is thrown when authentication is needed from the
@@ -60,7 +60,7 @@
*/
public AuthenticationRequiredException(Throwable cause, PendingIntent userAction) {
super(cause.getMessage());
- mUserAction = Preconditions.checkNotNull(userAction);
+ mUserAction = Objects.requireNonNull(userAction);
}
/**
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index bd87fcd..cd84310 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -2794,7 +2794,7 @@
public ApplicationContentResolver(Context context, ActivityThread mainThread) {
super(context);
- mMainThread = Preconditions.checkNotNull(mainThread);
+ mMainThread = Objects.requireNonNull(mainThread);
}
@Override
diff --git a/core/java/android/app/DirectAction.java b/core/java/android/app/DirectAction.java
index ef3627b..0268f7c 100644
--- a/core/java/android/app/DirectAction.java
+++ b/core/java/android/app/DirectAction.java
@@ -172,7 +172,7 @@
* current application state.
*/
public Builder(@NonNull String id) {
- Preconditions.checkNotNull(id);
+ Objects.requireNonNull(id);
mId = id;
}
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 31c73b9..ca3d0d7 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -198,6 +198,7 @@
import com.android.internal.util.Preconditions;
import java.util.Map;
+import java.util.Objects;
/**
* Manages all of the system services that can be returned by {@link Context#getSystemService}.
@@ -1429,8 +1430,8 @@
@NonNull StaticServiceProducerWithBinder<TServiceClass> serviceProducer) {
ensureInitializing("registerStaticService");
Preconditions.checkStringNotEmpty(serviceName);
- Preconditions.checkNotNull(serviceWrapperClass);
- Preconditions.checkNotNull(serviceProducer);
+ Objects.requireNonNull(serviceWrapperClass);
+ Objects.requireNonNull(serviceProducer);
registerService(serviceName, serviceWrapperClass,
new StaticServiceFetcher<TServiceClass>() {
@@ -1453,8 +1454,8 @@
@NonNull StaticServiceProducerWithoutBinder<TServiceClass> serviceProducer) {
ensureInitializing("registerStaticService");
Preconditions.checkStringNotEmpty(serviceName);
- Preconditions.checkNotNull(serviceWrapperClass);
- Preconditions.checkNotNull(serviceProducer);
+ Objects.requireNonNull(serviceWrapperClass);
+ Objects.requireNonNull(serviceProducer);
registerService(serviceName, serviceWrapperClass,
new StaticServiceFetcher<TServiceClass>() {
@@ -1486,8 +1487,8 @@
@NonNull ContextAwareServiceProducerWithBinder<TServiceClass> serviceProducer) {
ensureInitializing("registerContextAwareService");
Preconditions.checkStringNotEmpty(serviceName);
- Preconditions.checkNotNull(serviceWrapperClass);
- Preconditions.checkNotNull(serviceProducer);
+ Objects.requireNonNull(serviceWrapperClass);
+ Objects.requireNonNull(serviceProducer);
registerService(serviceName, serviceWrapperClass,
new CachedServiceFetcher<TServiceClass>() {
@@ -1514,8 +1515,8 @@
@NonNull ContextAwareServiceProducerWithoutBinder<TServiceClass> serviceProducer) {
ensureInitializing("registerContextAwareService");
Preconditions.checkStringNotEmpty(serviceName);
- Preconditions.checkNotNull(serviceWrapperClass);
- Preconditions.checkNotNull(serviceProducer);
+ Objects.requireNonNull(serviceWrapperClass);
+ Objects.requireNonNull(serviceProducer);
registerService(serviceName, serviceWrapperClass,
new CachedServiceFetcher<TServiceClass>() {
diff --git a/core/java/android/app/VoiceInteractor.java b/core/java/android/app/VoiceInteractor.java
index b37120f..c262ec2 100644
--- a/core/java/android/app/VoiceInteractor.java
+++ b/core/java/android/app/VoiceInteractor.java
@@ -44,6 +44,7 @@
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.Objects;
import java.util.concurrent.Executor;
/**
@@ -1129,8 +1130,8 @@
*/
public boolean registerOnDestroyedCallback(@NonNull @CallbackExecutor Executor executor,
@NonNull Runnable callback) {
- Preconditions.checkNotNull(executor);
- Preconditions.checkNotNull(callback);
+ Objects.requireNonNull(executor);
+ Objects.requireNonNull(callback);
if (isDestroyed()) {
Log.w(TAG, "Cannot interact with a destroyed voice interactor");
return false;
@@ -1146,7 +1147,7 @@
* @return whether the callback was unregistered.
*/
public boolean unregisterOnDestroyedCallback(@NonNull Runnable callback) {
- Preconditions.checkNotNull(callback);
+ Objects.requireNonNull(callback);
if (isDestroyed()) {
Log.w(TAG, "Cannot interact with a destroyed voice interactor");
return false;
diff --git a/core/java/android/app/admin/DevicePolicyEventLogger.java b/core/java/android/app/admin/DevicePolicyEventLogger.java
index 95a7973..4c0e176 100644
--- a/core/java/android/app/admin/DevicePolicyEventLogger.java
+++ b/core/java/android/app/admin/DevicePolicyEventLogger.java
@@ -25,6 +25,7 @@
import com.android.internal.util.Preconditions;
import java.util.Arrays;
+import java.util.Objects;
/**
* A wrapper for logging managed device events using {@link StatsLog}.
@@ -136,7 +137,7 @@
* in that order.
*/
public DevicePolicyEventLogger setStrings(String value, String[] values) {
- Preconditions.checkNotNull(values, "values parameter cannot be null");
+ Objects.requireNonNull(values, "values parameter cannot be null");
mStringArrayValue = new String[values.length + 1];
mStringArrayValue[0] = value;
System.arraycopy(values, 0, mStringArrayValue, 1, values.length);
@@ -150,7 +151,7 @@
* and <code>values</code>, in that order.
*/
public DevicePolicyEventLogger setStrings(String value1, String value2, String[] values) {
- Preconditions.checkNotNull(values, "values parameter cannot be null");
+ Objects.requireNonNull(values, "values parameter cannot be null");
mStringArrayValue = new String[values.length + 2];
mStringArrayValue[0] = value1;
mStringArrayValue[1] = value2;
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index acdf919..8daaaaa 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -115,6 +115,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -4263,7 +4264,7 @@
* {@link #WIPE_SILENTLY} is set.
*/
public void wipeData(int flags, @NonNull CharSequence reason) {
- Preconditions.checkNotNull(reason, "reason string is null");
+ Objects.requireNonNull(reason, "reason string is null");
Preconditions.checkStringNotEmpty(reason, "reason string is empty");
Preconditions.checkArgument((flags & WIPE_SILENTLY) == 0, "WIPE_SILENTLY cannot be set");
wipeDataInternal(flags, reason.toString());
@@ -10430,8 +10431,8 @@
@NonNull String packageName, @NonNull @CallbackExecutor Executor executor,
@NonNull OnClearApplicationUserDataListener listener) {
throwIfParentInstance("clearAppData");
- Preconditions.checkNotNull(executor);
- Preconditions.checkNotNull(listener);
+ Objects.requireNonNull(executor);
+ Objects.requireNonNull(listener);
try {
mService.clearApplicationUserData(admin, packageName,
new IPackageDataObserver.Stub() {
@@ -10881,7 +10882,7 @@
@WorkerThread public @PrivateDnsModeErrorCodes int setGlobalPrivateDnsModeSpecifiedHost(
@NonNull ComponentName admin, @NonNull String privateDnsHost) {
throwIfParentInstance("setGlobalPrivateDnsModeSpecifiedHost");
- Preconditions.checkNotNull(privateDnsHost, "dns resolver is null");
+ Objects.requireNonNull(privateDnsHost, "dns resolver is null");
if (mService == null) {
return PRIVATE_DNS_SET_ERROR_FAILURE_SETTING;
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java
index 80c5b17..22d8c87 100644
--- a/core/java/android/app/assist/AssistStructure.java
+++ b/core/java/android/app/assist/AssistStructure.java
@@ -41,6 +41,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
/**
* <p>This API automatically creates assist data from the platform's
@@ -1889,7 +1890,7 @@
@Override
public void setTextIdEntry(@NonNull String entryName) {
- mNode.mTextIdEntry = Preconditions.checkNotNull(entryName);
+ mNode.mTextIdEntry = Objects.requireNonNull(entryName);
}
@Override
@@ -1899,7 +1900,7 @@
@Override
public void setHintIdEntry(@NonNull String entryName) {
- mNode.mHintIdEntry = Preconditions.checkNotNull(entryName);
+ mNode.mHintIdEntry = Objects.requireNonNull(entryName);
}
@Override
diff --git a/core/java/android/app/prediction/AppPredictionManager.java b/core/java/android/app/prediction/AppPredictionManager.java
index cb5b7e7..ca22721 100644
--- a/core/java/android/app/prediction/AppPredictionManager.java
+++ b/core/java/android/app/prediction/AppPredictionManager.java
@@ -20,7 +20,7 @@
import android.annotation.TestApi;
import android.content.Context;
-import com.android.internal.util.Preconditions;
+import java.util.Objects;
/**
* Class that provides methods to create prediction clients.
@@ -37,7 +37,7 @@
* @hide
*/
public AppPredictionManager(Context context) {
- mContext = Preconditions.checkNotNull(context);
+ mContext = Objects.requireNonNull(context);
}
/**
diff --git a/core/java/android/app/prediction/AppTarget.java b/core/java/android/app/prediction/AppTarget.java
index 6f21490..14e32b83 100644
--- a/core/java/android/app/prediction/AppTarget.java
+++ b/core/java/android/app/prediction/AppTarget.java
@@ -25,7 +25,7 @@
import android.os.Parcelable;
import android.os.UserHandle;
-import com.android.internal.util.Preconditions;
+import java.util.Objects;
/**
* A representation of a launchable target.
@@ -55,9 +55,9 @@
mId = id;
mShortcutInfo = null;
- mPackageName = Preconditions.checkNotNull(packageName);
+ mPackageName = Objects.requireNonNull(packageName);
mClassName = className;
- mUser = Preconditions.checkNotNull(user);
+ mUser = Objects.requireNonNull(user);
mRank = 0;
}
@@ -69,7 +69,7 @@
public AppTarget(@NonNull AppTargetId id, @NonNull ShortcutInfo shortcutInfo,
@Nullable String className) {
mId = id;
- mShortcutInfo = Preconditions.checkNotNull(shortcutInfo);
+ mShortcutInfo = Objects.requireNonNull(shortcutInfo);
mPackageName = mShortcutInfo.getPackage();
mUser = mShortcutInfo.getUserHandle();
@@ -224,9 +224,9 @@
@TestApi
public Builder(@NonNull AppTargetId id, @NonNull String packageName,
@NonNull UserHandle user) {
- mId = Preconditions.checkNotNull(id);
- mPackageName = Preconditions.checkNotNull(packageName);
- mUser = Preconditions.checkNotNull(user);
+ mId = Objects.requireNonNull(id);
+ mPackageName = Objects.requireNonNull(packageName);
+ mUser = Objects.requireNonNull(user);
}
/**
@@ -237,8 +237,8 @@
@SystemApi
@TestApi
public Builder(@NonNull AppTargetId id, @NonNull ShortcutInfo info) {
- mId = Preconditions.checkNotNull(id);
- mShortcutInfo = Preconditions.checkNotNull(info);
+ mId = Objects.requireNonNull(id);
+ mShortcutInfo = Objects.requireNonNull(info);
mPackageName = info.getPackage();
mUser = info.getUserHandle();
}
@@ -253,8 +253,8 @@
if (mPackageName != null) {
throw new IllegalArgumentException("Target is already set");
}
- mPackageName = Preconditions.checkNotNull(packageName);
- mUser = Preconditions.checkNotNull(user);
+ mPackageName = Objects.requireNonNull(packageName);
+ mUser = Objects.requireNonNull(user);
return this;
}
@@ -266,7 +266,7 @@
@Deprecated
public Builder setTarget(@NonNull ShortcutInfo info) {
setTarget(info.getPackage(), info.getUserHandle());
- mShortcutInfo = Preconditions.checkNotNull(info);
+ mShortcutInfo = Objects.requireNonNull(info);
return this;
}
@@ -275,7 +275,7 @@
*/
@NonNull
public Builder setClassName(@NonNull String className) {
- mClassName = Preconditions.checkNotNull(className);
+ mClassName = Objects.requireNonNull(className);
return this;
}
diff --git a/core/java/android/app/slice/Slice.java b/core/java/android/app/slice/Slice.java
index a7319f6..823fdd2 100644
--- a/core/java/android/app/slice/Slice.java
+++ b/core/java/android/app/slice/Slice.java
@@ -28,7 +28,6 @@
import android.os.Parcelable;
import com.android.internal.util.ArrayUtils;
-import com.android.internal.util.Preconditions;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -428,7 +427,7 @@
* @see SliceItem#getSubType()
*/
public Builder addSubSlice(@NonNull Slice slice, @Nullable @SliceSubtype String subType) {
- Preconditions.checkNotNull(slice);
+ Objects.requireNonNull(slice);
mItems.add(new SliceItem(slice, SliceItem.FORMAT_SLICE, subType,
slice.getHints().toArray(new String[slice.getHints().size()])));
return this;
@@ -441,8 +440,8 @@
*/
public Slice.Builder addAction(@NonNull PendingIntent action, @NonNull Slice s,
@Nullable @SliceSubtype String subType) {
- Preconditions.checkNotNull(action);
- Preconditions.checkNotNull(s);
+ Objects.requireNonNull(action);
+ Objects.requireNonNull(s);
List<String> hints = s.getHints();
s.mSpec = null;
mItems.add(new SliceItem(action, s, SliceItem.FORMAT_ACTION, subType, hints.toArray(
@@ -468,7 +467,7 @@
*/
public Builder addIcon(Icon icon, @Nullable @SliceSubtype String subType,
@SliceHint List<String> hints) {
- Preconditions.checkNotNull(icon);
+ Objects.requireNonNull(icon);
mItems.add(new SliceItem(icon, SliceItem.FORMAT_IMAGE, subType, hints));
return this;
}
@@ -481,7 +480,7 @@
public Slice.Builder addRemoteInput(RemoteInput remoteInput,
@Nullable @SliceSubtype String subType,
@SliceHint List<String> hints) {
- Preconditions.checkNotNull(remoteInput);
+ Objects.requireNonNull(remoteInput);
mItems.add(new SliceItem(remoteInput, SliceItem.FORMAT_REMOTE_INPUT,
subType, hints));
return this;
@@ -529,7 +528,7 @@
*/
public Slice.Builder addBundle(Bundle bundle, @Nullable @SliceSubtype String subType,
@SliceHint List<String> hints) {
- Preconditions.checkNotNull(bundle);
+ Objects.requireNonNull(bundle);
mItems.add(new SliceItem(bundle, SliceItem.FORMAT_BUNDLE, subType,
hints));
return this;
diff --git a/core/java/android/app/slice/SliceManager.java b/core/java/android/app/slice/SliceManager.java
index 90ecce2..4da1acb 100644
--- a/core/java/android/app/slice/SliceManager.java
+++ b/core/java/android/app/slice/SliceManager.java
@@ -51,6 +51,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
/**
@@ -241,7 +242,7 @@
* @see Slice
*/
public @Nullable Slice bindSlice(@NonNull Uri uri, @NonNull Set<SliceSpec> supportedSpecs) {
- Preconditions.checkNotNull(uri, "uri");
+ Objects.requireNonNull(uri, "uri");
ContentResolver resolver = mContext.getContentResolver();
try (ContentProviderClient provider = resolver.acquireUnstableContentProviderClient(uri)) {
if (provider == null) {
@@ -336,7 +337,7 @@
}
private Uri resolveStatic(@NonNull Intent intent, ContentResolver resolver) {
- Preconditions.checkNotNull(intent, "intent");
+ Objects.requireNonNull(intent, "intent");
Preconditions.checkArgument(intent.getComponent() != null || intent.getPackage() != null
|| intent.getData() != null,
"Slice intent must be explicit %s", intent);
@@ -371,7 +372,7 @@
*/
public @Nullable Slice bindSlice(@NonNull Intent intent,
@NonNull Set<SliceSpec> supportedSpecs) {
- Preconditions.checkNotNull(intent, "intent");
+ Objects.requireNonNull(intent, "intent");
Preconditions.checkArgument(intent.getComponent() != null || intent.getPackage() != null
|| intent.getData() != null,
"Slice intent must be explicit %s", intent);
diff --git a/core/java/android/app/usage/NetworkStatsManager.java b/core/java/android/app/usage/NetworkStatsManager.java
index 7412970..4346d97 100644
--- a/core/java/android/app/usage/NetworkStatsManager.java
+++ b/core/java/android/app/usage/NetworkStatsManager.java
@@ -16,8 +16,6 @@
package android.app.usage;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import android.annotation.Nullable;
import android.annotation.SystemService;
import android.annotation.TestApi;
@@ -42,6 +40,8 @@
import com.android.internal.annotations.VisibleForTesting;
+import java.util.Objects;
+
/**
* Provides access to network usage history and statistics. Usage data is collected in
* discrete bins of time called 'Buckets'. See {@link NetworkStats.Bucket} for details.
@@ -418,7 +418,7 @@
/** @hide */
public void registerUsageCallback(NetworkTemplate template, int networkType,
long thresholdBytes, UsageCallback callback, @Nullable Handler handler) {
- checkNotNull(callback, "UsageCallback cannot be null");
+ Objects.requireNonNull(callback, "UsageCallback cannot be null");
final Looper looper;
if (handler == null) {
diff --git a/core/java/android/app/usage/StorageStatsManager.java b/core/java/android/app/usage/StorageStatsManager.java
index eecf092..1ef1563 100644
--- a/core/java/android/app/usage/StorageStatsManager.java
+++ b/core/java/android/app/usage/StorageStatsManager.java
@@ -63,8 +63,8 @@
/** {@hide} */
public StorageStatsManager(Context context, IStorageStatsManager service) {
- mContext = Preconditions.checkNotNull(context);
- mService = Preconditions.checkNotNull(service);
+ mContext = Objects.requireNonNull(context);
+ mService = Objects.requireNonNull(service);
}
/** {@hide} */
diff --git a/core/java/android/content/pm/VersionedPackage.java b/core/java/android/content/pm/VersionedPackage.java
index 3e22eb2..21df7ec 100644
--- a/core/java/android/content/pm/VersionedPackage.java
+++ b/core/java/android/content/pm/VersionedPackage.java
@@ -96,6 +96,20 @@
}
@Override
+ public boolean equals(Object o) {
+ return o instanceof VersionedPackage
+ && ((VersionedPackage) o).mPackageName.equals(mPackageName)
+ && ((VersionedPackage) o).mVersionCode == mVersionCode;
+ }
+
+ @Override
+ public int hashCode() {
+ // Roll our own hash function without using Objects#hash which incurs the overhead
+ // of autoboxing.
+ return 31 * mPackageName.hashCode() + Long.hashCode(mVersionCode);
+ }
+
+ @Override
public int describeContents() {
return 0;
}
diff --git a/core/java/android/service/controls/ControlsProviderService.java b/core/java/android/service/controls/ControlsProviderService.java
index 258ef23..eca8541 100644
--- a/core/java/android/service/controls/ControlsProviderService.java
+++ b/core/java/android/service/controls/ControlsProviderService.java
@@ -20,7 +20,6 @@
import android.annotation.SdkConstant.SdkConstantType;
import android.app.Service;
import android.content.Intent;
-import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -88,7 +87,7 @@
* {@link Control.StatelessBuilder}).
* @param controls
*/
- public void onLoad(@NonNull List<Control> controls) {
+ public final void onLoad(@NonNull List<Control> controls) {
Preconditions.checkNotNull(controls);
List<Control> list = new ArrayList<>();
for (Control control: controls) {
@@ -114,7 +113,7 @@
* their state.
* @param statefulControls
*/
- public void onRefreshState(@NonNull List<Control> statefulControls) {
+ public final void onRefreshState(@NonNull List<Control> statefulControls) {
Preconditions.checkNotNull(statefulControls);
try {
mCallback.onRefreshState(mToken, statefulControls);
@@ -128,7 +127,7 @@
* @param controlId
* @param response
*/
- public void onControlActionResponse(
+ public final void onControlActionResponse(
@NonNull String controlId, @ControlAction.ResponseResult int response) {
Preconditions.checkNotNull(controlId);
if (!ControlAction.isValidResponse(response)) {
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 3b6a009..f6aaa6f 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -139,6 +139,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
/**
* Helper class used by TextView to handle editable text views.
@@ -7062,11 +7063,11 @@
private final List<ResolveInfo> mSupportedActivities = new ArrayList<>();
private ProcessTextIntentActionsHandler(Editor editor) {
- mEditor = Preconditions.checkNotNull(editor);
- mTextView = Preconditions.checkNotNull(mEditor.mTextView);
- mContext = Preconditions.checkNotNull(mTextView.getContext());
- mPackageManager = Preconditions.checkNotNull(mContext.getPackageManager());
- mPackageName = Preconditions.checkNotNull(mContext.getPackageName());
+ mEditor = Objects.requireNonNull(editor);
+ mTextView = Objects.requireNonNull(mEditor.mTextView);
+ mContext = Objects.requireNonNull(mTextView.getContext());
+ mPackageManager = Objects.requireNonNull(mContext.getPackageManager());
+ mPackageName = Objects.requireNonNull(mContext.getPackageName());
}
/**
diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java
index f58b6d1..2924dd9 100644
--- a/core/java/android/widget/Magnifier.java
+++ b/core/java/android/widget/Magnifier.java
@@ -62,6 +62,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.Objects;
/**
* Android magnifier widget. Can be used by any view which is attached to a window.
@@ -1154,7 +1155,7 @@
* @param view the view this magnifier is attached to
*/
public Builder(@NonNull View view) {
- mView = Preconditions.checkNotNull(view);
+ mView = Objects.requireNonNull(view);
applyDefaults();
}
diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java
index d0f8093..4ef3f61 100644
--- a/core/java/android/widget/SelectionActionModeHelper.java
+++ b/core/java/android/widget/SelectionActionModeHelper.java
@@ -87,7 +87,7 @@
private final SmartSelectSprite mSmartSelectSprite;
SelectionActionModeHelper(@NonNull Editor editor) {
- mEditor = Preconditions.checkNotNull(editor);
+ mEditor = Objects.requireNonNull(editor);
mTextView = mEditor.getTextView();
mTextClassificationHelper = new TextClassificationHelper(
mTextView.getContext(),
@@ -500,7 +500,7 @@
private final LogAbandonRunnable mDelayedLogAbandon = new LogAbandonRunnable();
SelectionTracker(TextView textView) {
- mTextView = Preconditions.checkNotNull(textView);
+ mTextView = Objects.requireNonNull(textView);
mLogger = new SelectionMetricsLogger(textView);
}
@@ -703,7 +703,7 @@
private String mText;
SelectionMetricsLogger(TextView textView) {
- Preconditions.checkNotNull(textView);
+ Objects.requireNonNull(textView);
mEditTextLogger = textView.isTextEditable();
mTokenIterator = SelectionSessionLogger.getTokenIterator(textView.getTextLocale());
}
@@ -714,7 +714,7 @@
CharSequence text, int index,
@InvocationMethod int invocationMethod) {
try {
- Preconditions.checkNotNull(text);
+ Objects.requireNonNull(text);
Preconditions.checkArgumentInRange(index, 0, text.length(), "index");
if (mText == null || !mText.contentEquals(text)) {
mText = text.toString();
@@ -972,11 +972,11 @@
@NonNull Consumer<SelectionResult> selectionResultCallback,
@NonNull Supplier<SelectionResult> timeOutResultSupplier) {
super(textView != null ? textView.getHandler() : null);
- mTextView = Preconditions.checkNotNull(textView);
+ mTextView = Objects.requireNonNull(textView);
mTimeOutDuration = timeOut;
- mSelectionResultSupplier = Preconditions.checkNotNull(selectionResultSupplier);
- mSelectionResultCallback = Preconditions.checkNotNull(selectionResultCallback);
- mTimeOutResultSupplier = Preconditions.checkNotNull(timeOutResultSupplier);
+ mSelectionResultSupplier = Objects.requireNonNull(selectionResultSupplier);
+ mSelectionResultCallback = Objects.requireNonNull(selectionResultCallback);
+ mTimeOutResultSupplier = Objects.requireNonNull(timeOutResultSupplier);
// Make a copy of the original text.
mOriginalText = getText(mTextView).toString();
}
@@ -1051,14 +1051,14 @@
TextClassificationHelper(Context context, Supplier<TextClassifier> textClassifier,
CharSequence text, int selectionStart, int selectionEnd, LocaleList locales) {
init(textClassifier, text, selectionStart, selectionEnd, locales);
- mContext = Preconditions.checkNotNull(context);
+ mContext = Objects.requireNonNull(context);
}
@UiThread
public void init(Supplier<TextClassifier> textClassifier, CharSequence text,
int selectionStart, int selectionEnd, LocaleList locales) {
- mTextClassifier = Preconditions.checkNotNull(textClassifier);
- mText = Preconditions.checkNotNull(text).toString();
+ mTextClassifier = Objects.requireNonNull(textClassifier);
+ mText = Objects.requireNonNull(text).toString();
mLastClassificationText = null; // invalidate.
Preconditions.checkArgument(selectionEnd > selectionStart);
mSelectionStart = selectionStart;
diff --git a/core/java/android/widget/SmartSelectSprite.java b/core/java/android/widget/SmartSelectSprite.java
index 9a84f69..dc472e1 100644
--- a/core/java/android/widget/SmartSelectSprite.java
+++ b/core/java/android/widget/SmartSelectSprite.java
@@ -38,13 +38,12 @@
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
-import com.android.internal.util.Preconditions;
-
import java.lang.annotation.Retention;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Objects;
/**
* A utility class for creating and animating the Smart Select animation.
@@ -75,7 +74,7 @@
private final int mTextSelectionLayout;
RectangleWithTextSelectionLayout(RectF rectangle, int textSelectionLayout) {
- mRectangle = Preconditions.checkNotNull(rectangle);
+ mRectangle = Objects.requireNonNull(rectangle);
mTextSelectionLayout = textSelectionLayout;
}
@@ -342,7 +341,7 @@
context,
android.R.interpolator.fast_out_linear_in);
mFillColor = highlightColor;
- mInvalidator = Preconditions.checkNotNull(invalidator);
+ mInvalidator = Objects.requireNonNull(invalidator);
}
/**
diff --git a/media/Android.bp b/media/Android.bp
index a136517..499d0da 100644
--- a/media/Android.bp
+++ b/media/Android.bp
@@ -1,110 +1,3 @@
-java_library {
- name: "updatable-media",
-
- srcs: [
- ":updatable-media-srcs",
- ],
-
- aidl: {
- export_include_dirs: [
- "apex/java",
- ],
-
- // It would be great if we don't need to add include_dirs for public
- // parcelable classes. Find a better way.
- include_dirs: [
- // To refer:
- // android.os.Bundle
- // android.os.ResultReceiver
- "frameworks/base/core/java",
- ],
- },
-
- permitted_packages: [
- "android.media",
- ],
-
- installable: true,
-
- // TODO: build against stable API surface. Use core_platform for now to avoid
- // link-check failure with exoplayer building against "current".
- sdk_version: "core_platform",
- libs: [
- // The order matters. android_system_* library should come later.
- "framework_media_annotation",
- "android_system_stubs_current",
- ],
-
- static_libs: [
- "exoplayer2-core"
- ],
- jarjar_rules: "jarjar_rules.txt",
-
- plugins: ["java_api_finder"],
-}
-
-filegroup {
- name: "updatable-media-srcs",
- srcs: [
- ":mediaparser-srcs",
- ":mediasession2-srcs",
- ],
-}
-
-filegroup {
- name: "mediasession2-srcs",
- srcs: [
- "apex/java/android/media/Controller2Link.java",
- "apex/java/android/media/IMediaController2.aidl",
- "apex/java/android/media/IMediaSession2.aidl",
- "apex/java/android/media/IMediaSession2Service.aidl",
- "apex/java/android/media/MediaConstants.java",
- "apex/java/android/media/MediaController2.java",
- "apex/java/android/media/MediaSession2.java",
- "apex/java/android/media/MediaSession2Service.java",
- "apex/java/android/media/Session2Command.java",
- "apex/java/android/media/Session2CommandGroup.java",
- "apex/java/android/media/Session2Link.java",
- "apex/java/android/media/Session2Token.java",
- ],
- path: "apex/java",
-}
-
-filegroup {
- name: "mediaparser-srcs",
- srcs: [
- "apex/java/android/media/MediaParser.java"
- ],
- path: "apex/java"
-}
-
-droidstubs {
- name: "updatable-media-stubs",
- srcs: [
- ":updatable-media-srcs",
- ":framework-media-annotation-srcs",
- ],
- defaults: [ "framework-module-stubs-defaults-systemapi" ],
- aidl: {
- // TODO(b/135922046) remove this
- include_dirs: ["frameworks/base/core/java"],
- },
- sdk_version: "system_current",
-}
-
-java_library {
- name: "updatable_media_stubs",
- srcs: [":updatable-media-stubs"],
- sdk_version: "system_current",
-}
-
-java_library {
- name: "framework_media_annotation",
- srcs: [":framework-media-annotation-srcs"],
- installable: false,
- sdk_version: "core_current",
-}
-
aidl_interface {
name: "audio_common-aidl",
local_include_dir: "java",
diff --git a/media/apex/java/android/media/CloseGuard.java b/media/apex/java/android/media/CloseGuard.java
deleted file mode 100644
index 2014673..0000000
--- a/media/apex/java/android/media/CloseGuard.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media;
-
-import android.util.Log;
-
-/**
- * Note: This file is copied from dalvik.system package with the following modifications:
- * - Remove @CorePlatformApi, @IntraCoreApi and @UnsupportedAppUsage annotations.
- * - Replace System.logW() with android.util.Log.w().
- * This file should be used only within media mainline module.
- * TODO: Remove this file and use dalvik.system.CloseGuard once
- * @CorePlatformApi becomes stable or we have a replacement in SDK API.
- * b/120419300
- *
- * CloseGuard is a mechanism for flagging implicit finalizer cleanup of
- * resources that should have been cleaned up by explicit close
- * methods (aka "explicit termination methods" in Effective Java).
- * <p>
- * A simple example: <pre> {@code
- * class Foo {
- *
- * {@literal @}ReachabilitySensitive
- * private final CloseGuard guard = CloseGuard.get();
- *
- * ...
- *
- * public Foo() {
- * ...;
- * guard.open("cleanup");
- * }
- *
- * public void cleanup() {
- * guard.close();
- * ...;
- * }
- *
- * protected void finalize() throws Throwable {
- * try {
- * // Note that guard could be null if the constructor threw.
- * if (guard != null) {
- * guard.warnIfOpen();
- * }
- * cleanup();
- * } finally {
- * super.finalize();
- * }
- * }
- * }
- * }</pre>
- *
- * In usage where the resource to be explicitly cleaned up is
- * allocated after object construction, CloseGuard protection can
- * be deferred. For example: <pre> {@code
- * class Bar {
- *
- * {@literal @}ReachabilitySensitive
- * private final CloseGuard guard = CloseGuard.get();
- *
- * ...
- *
- * public Bar() {
- * ...;
- * }
- *
- * public void connect() {
- * ...;
- * guard.open("cleanup");
- * }
- *
- * public void cleanup() {
- * guard.close();
- * ...;
- * }
- *
- * protected void finalize() throws Throwable {
- * try {
- * // Note that guard could be null if the constructor threw.
- * if (guard != null) {
- * guard.warnIfOpen();
- * }
- * cleanup();
- * } finally {
- * super.finalize();
- * }
- * }
- * }
- * }</pre>
- *
- * When used in a constructor, calls to {@code open} should occur at
- * the end of the constructor since an exception that would cause
- * abrupt termination of the constructor will mean that the user will
- * not have a reference to the object to cleanup explicitly. When used
- * in a method, the call to {@code open} should occur just after
- * resource acquisition.
- *
- * The @ReachabilitySensitive annotation ensures that finalize() cannot be
- * called during the explicit call to cleanup(), prior to the guard.close call.
- * There is an extremely small chance that, for code that neglects to call
- * cleanup(), finalize() and thus cleanup() will be called while a method on
- * the object is still active, but the "this" reference is no longer required.
- * If missing cleanup() calls are expected, additional @ReachabilitySensitive
- * annotations or reachabilityFence() calls may be required.
- *
- * @hide
- */
-final class CloseGuard {
-
- /**
- * True if collection of call-site information (the expensive operation
- * here) and tracking via a Tracker (see below) are enabled.
- * Enabled by default so we can diagnose issues early in VM startup.
- * Note, however, that Android disables this early in its startup,
- * but enables it with DropBoxing for system apps on debug builds.
- */
- private static volatile boolean stackAndTrackingEnabled = true;
-
- /**
- * Hook for customizing how CloseGuard issues are reported.
- * Bypassed if stackAndTrackingEnabled was false when open was called.
- */
- private static volatile Reporter reporter = new DefaultReporter();
-
- /**
- * Hook for customizing how CloseGuard issues are tracked.
- */
- private static volatile Tracker currentTracker = null; // Disabled by default.
-
- /**
- * Returns a CloseGuard instance. {@code #open(String)} can be used to set
- * up the instance to warn on failure to close.
- */
- public static CloseGuard get() {
- return new CloseGuard();
- }
-
- /**
- * Enables/disables stack capture and tracking. A call stack is captured
- * during open(), and open/close events are reported to the Tracker, only
- * if enabled is true. If a stack trace was captured, the {@link
- * #getReporter() reporter} is informed of unclosed resources; otherwise a
- * one-line warning is logged.
- */
- public static void setEnabled(boolean enabled) {
- CloseGuard.stackAndTrackingEnabled = enabled;
- }
-
- /**
- * True if CloseGuard stack capture and tracking are enabled.
- */
- public static boolean isEnabled() {
- return stackAndTrackingEnabled;
- }
-
- /**
- * Used to replace default Reporter used to warn of CloseGuard
- * violations when stack tracking is enabled. Must be non-null.
- */
- public static void setReporter(Reporter rep) {
- if (rep == null) {
- throw new NullPointerException("reporter == null");
- }
- CloseGuard.reporter = rep;
- }
-
- /**
- * Returns non-null CloseGuard.Reporter.
- */
- public static Reporter getReporter() {
- return reporter;
- }
-
- /**
- * Sets the {@link Tracker} that is notified when resources are allocated and released.
- * The Tracker is invoked only if CloseGuard {@link #isEnabled()} held when {@link #open()}
- * was called. A null argument disables tracking.
- *
- * <p>This is only intended for use by {@code dalvik.system.CloseGuardSupport} class and so
- * MUST NOT be used for any other purposes.
- */
- public static void setTracker(Tracker tracker) {
- currentTracker = tracker;
- }
-
- /**
- * Returns {@link #setTracker(Tracker) last Tracker that was set}, or null to indicate
- * there is none.
- *
- * <p>This is only intended for use by {@code dalvik.system.CloseGuardSupport} class and so
- * MUST NOT be used for any other purposes.
- */
- public static Tracker getTracker() {
- return currentTracker;
- }
-
- private CloseGuard() {}
-
- /**
- * {@code open} initializes the instance with a warning that the caller
- * should have explicitly called the {@code closer} method instead of
- * relying on finalization.
- *
- * @param closer non-null name of explicit termination method. Printed by warnIfOpen.
- * @throws NullPointerException if closer is null.
- */
- public void open(String closer) {
- // always perform the check for valid API usage...
- if (closer == null) {
- throw new NullPointerException("closer == null");
- }
- // ...but avoid allocating an allocation stack if "disabled"
- if (!stackAndTrackingEnabled) {
- closerNameOrAllocationInfo = closer;
- return;
- }
- String message = "Explicit termination method '" + closer + "' not called";
- Throwable stack = new Throwable(message);
- closerNameOrAllocationInfo = stack;
- Tracker tracker = currentTracker;
- if (tracker != null) {
- tracker.open(stack);
- }
- }
-
- // We keep either an allocation stack containing the closer String or, when
- // in disabled state, just the closer String.
- // We keep them in a single field only to minimize overhead.
- private Object /* String or Throwable */ closerNameOrAllocationInfo;
-
- /**
- * Marks this CloseGuard instance as closed to avoid warnings on
- * finalization.
- */
- public void close() {
- Tracker tracker = currentTracker;
- if (tracker != null && closerNameOrAllocationInfo instanceof Throwable) {
- // Invoke tracker on close only if we invoked it on open. Tracker may have changed.
- tracker.close((Throwable) closerNameOrAllocationInfo);
- }
- closerNameOrAllocationInfo = null;
- }
-
- /**
- * Logs a warning if the caller did not properly cleanup by calling an
- * explicit close method before finalization. If CloseGuard was enabled
- * when the CloseGuard was created, passes the stacktrace associated with
- * the allocation to the current reporter. If it was not enabled, it just
- * directly logs a brief message.
- */
- public void warnIfOpen() {
- if (closerNameOrAllocationInfo != null) {
- if (closerNameOrAllocationInfo instanceof String) {
- Log.w("CloseGuard", "A resource failed to call "
- + (String) closerNameOrAllocationInfo + ". ");
- } else {
- String message =
- "A resource was acquired at attached stack trace but never released. ";
- message += "See java.io.Closeable for information on avoiding resource leaks.";
- Throwable stack = (Throwable) closerNameOrAllocationInfo;
- reporter.report(message, stack);
- }
- }
- }
-
- /**
- * Interface to allow customization of tracking behaviour.
- *
- * <p>This is only intended for use by {@code dalvik.system.CloseGuardSupport} class and so
- * MUST NOT be used for any other purposes.
- */
- public interface Tracker {
- void open(Throwable allocationSite);
- void close(Throwable allocationSite);
- }
-
- /**
- * Interface to allow customization of reporting behavior.
- * @hide
- */
- public interface Reporter {
- void report(String message, Throwable allocationSite);
- }
-
- /**
- * Default Reporter which reports CloseGuard violations to the log.
- */
- private static final class DefaultReporter implements Reporter {
- private DefaultReporter() {}
-
- @Override public void report (String message, Throwable allocationSite) {
- Log.w("CloseGuard", message, allocationSite);
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java b/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java
index 778443c..fdb793e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java
@@ -33,6 +33,7 @@
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* Keeps track of the currently active {@link RemoteInputView}s.
@@ -108,8 +109,8 @@
* @param token a token identifying the view that is managing the remote input
*/
public void addRemoteInput(NotificationEntry entry, Object token) {
- Preconditions.checkNotNull(entry);
- Preconditions.checkNotNull(token);
+ Objects.requireNonNull(entry);
+ Objects.requireNonNull(token);
boolean found = pruneWeakThenRemoveAndContains(
entry /* contains */, null /* remove */, token /* removeToken */);
@@ -129,7 +130,7 @@
* entry. If null, the entry is removed regardless.
*/
public void removeRemoteInput(NotificationEntry entry, Object token) {
- Preconditions.checkNotNull(entry);
+ Objects.requireNonNull(entry);
pruneWeakThenRemoveAndContains(null /* contains */, entry /* remove */, token);
@@ -143,8 +144,8 @@
* @param token the token of the view managing the remote input.
*/
public void addSpinning(String key, Object token) {
- Preconditions.checkNotNull(key);
- Preconditions.checkNotNull(token);
+ Objects.requireNonNull(key);
+ Objects.requireNonNull(token);
mSpinning.put(key, token);
}
@@ -158,7 +159,7 @@
* entry. If null, the entry is removed regardless.
*/
public void removeSpinning(String key, Object token) {
- Preconditions.checkNotNull(key);
+ Objects.requireNonNull(key);
if (token == null || mSpinning.get(key) == token) {
mSpinning.remove(key);
@@ -237,7 +238,7 @@
public void addCallback(Callback callback) {
- Preconditions.checkNotNull(callback);
+ Objects.requireNonNull(callback);
mCallbacks.add(callback);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationListController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationListController.java
index 7b1dc07..f2765db 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationListController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationListController.java
@@ -16,14 +16,14 @@
package com.android.systemui.statusbar.notification;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
+import java.util.Objects;
+
/**
* Root controller for the list of notifications in the shade.
*
@@ -39,9 +39,9 @@
NotificationEntryManager entryManager,
NotificationListContainer listContainer,
DeviceProvisionedController deviceProvisionedController) {
- mEntryManager = checkNotNull(entryManager);
- mListContainer = checkNotNull(listContainer);
- mDeviceProvisionedController = checkNotNull(deviceProvisionedController);
+ mEntryManager = Objects.requireNonNull(entryManager);
+ mListContainer = Objects.requireNonNull(listContainer);
+ mDeviceProvisionedController = Objects.requireNonNull(deviceProvisionedController);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
index 7f85c88..7df7568 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
@@ -35,8 +35,6 @@
import static android.service.notification.NotificationListenerService.REASON_UNAUTOBUNDLED;
import static android.service.notification.NotificationListenerService.REASON_USER_STOPPED;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import android.annotation.IntDef;
import android.annotation.MainThread;
import android.annotation.NonNull;
@@ -60,6 +58,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -170,7 +169,7 @@
@CancellationReason int reason,
@NonNull DismissedByUserStats stats) {
Assert.isMainThread();
- checkNotNull(stats);
+ Objects.requireNonNull(stats);
checkForReentrantCall();
removeNotification(entry.getKey(), null, reason, stats);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
index dd3a3e0..4f4fb24 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
@@ -29,7 +29,6 @@
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR;
-import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_ALERTING;
import android.annotation.NonNull;
@@ -162,9 +161,9 @@
public NotificationEntry(
@NonNull StatusBarNotification sbn,
@NonNull Ranking ranking) {
- super(checkNotNull(checkNotNull(sbn).getKey()));
+ super(Objects.requireNonNull(Objects.requireNonNull(sbn).getKey()));
- checkNotNull(ranking);
+ Objects.requireNonNull(ranking);
mKey = sbn.getKey();
setSbn(sbn);
@@ -194,8 +193,8 @@
* TODO: Make this package-private
*/
public void setSbn(@NonNull StatusBarNotification sbn) {
- checkNotNull(sbn);
- checkNotNull(sbn.getKey());
+ Objects.requireNonNull(sbn);
+ Objects.requireNonNull(sbn.getKey());
if (!sbn.getKey().equals(mKey)) {
throw new IllegalArgumentException("New key " + sbn.getKey()
@@ -223,8 +222,8 @@
* TODO: Make this package-private
*/
public void setRanking(@NonNull Ranking ranking) {
- checkNotNull(ranking);
- checkNotNull(ranking.getKey());
+ Objects.requireNonNull(ranking);
+ Objects.requireNonNull(ranking.getKey());
if (!ranking.getKey().equals(mKey)) {
throw new IllegalArgumentException("New key " + ranking.getKey()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRowBinderImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRowBinderImpl.java
index 8afbc27..6c93618 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRowBinderImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRowBinderImpl.java
@@ -16,7 +16,6 @@
package com.android.systemui.statusbar.notification.collection;
-import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENABLE_REMOTE_INPUT;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_HEADS_UP;
@@ -51,6 +50,8 @@
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.HeadsUpManager;
+import java.util.Objects;
+
/** Handles inflating and updating views for notifications. */
public class NotificationRowBinderImpl implements NotificationRowBinder {
@@ -265,7 +266,7 @@
row.inflateViews();
// bind the click event to the content area
- checkNotNull(mNotificationClicker).register(row, sbn);
+ Objects.requireNonNull(mNotificationClicker).register(row, sbn);
}
private void logNotificationExpansion(String key, boolean userAction, boolean expanded) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/SectionHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/SectionHeaderView.java
index b444fa5..add982d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/SectionHeaderView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/SectionHeaderView.java
@@ -16,8 +16,6 @@
package com.android.systemui.statusbar.notification.stack;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import android.annotation.Nullable;
import android.content.Context;
import android.graphics.RectF;
@@ -32,6 +30,8 @@
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
+import java.util.Objects;
+
/**
* Similar in size and appearance to the NotificationShelf, appears at the beginning of some
* notification sections. Currently only used for gentle notifications.
@@ -51,13 +51,13 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- mContents = checkNotNull(findViewById(R.id.content));
+ mContents = Objects.requireNonNull(findViewById(R.id.content));
bindContents();
}
private void bindContents() {
- mLabelView = checkNotNull(findViewById(R.id.header_label));
- mClearAllButton = checkNotNull(findViewById(R.id.btn_clear_all));
+ mLabelView = Objects.requireNonNull(findViewById(R.id.header_label));
+ mClearAllButton = Objects.requireNonNull(findViewById(R.id.btn_clear_all));
if (mOnClearClickListener != null) {
mClearAllButton.setOnClickListener(mOnClearClickListener);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java
index b198678..88edf8e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java
@@ -23,11 +23,11 @@
import android.view.View;
import android.widget.FrameLayout;
-import com.android.internal.util.Preconditions;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.NotificationPanelView;
import com.android.systemui.statusbar.phone.StatusBarWindowView;
+import java.util.Objects;
import java.util.function.Consumer;
/**
@@ -117,7 +117,7 @@
@Override
public void addCallback(BrightnessMirrorListener listener) {
- Preconditions.checkNotNull(listener);
+ Objects.requireNonNull(listener);
mBrightnessMirrorListeners.add(listener);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java
index 1cb2bd4..0ab08a8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java
@@ -27,7 +27,6 @@
import androidx.annotation.VisibleForTesting;
-import com.android.internal.util.Preconditions;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
@@ -36,6 +35,7 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -98,7 +98,7 @@
@Override
public void addCallback(@NonNull Callback callback) {
- Preconditions.checkNotNull(callback, "Callback must not be null. b/128895449");
+ Objects.requireNonNull(callback, "Callback must not be null. b/128895449");
if (!mCallbacks.contains(callback)) {
mCallbacks.add(callback);
}
@@ -106,7 +106,7 @@
@Override
public void removeCallback(@NonNull Callback callback) {
- Preconditions.checkNotNull(callback, "Callback must not be null. b/128895449");
+ Objects.requireNonNull(callback, "Callback must not be null. b/128895449");
mCallbacks.remove(callback);
}
diff --git a/packages/SystemUI/src/com/android/systemui/util/wakelock/SettableWakeLock.java b/packages/SystemUI/src/com/android/systemui/util/wakelock/SettableWakeLock.java
index a797287..37da236 100644
--- a/packages/SystemUI/src/com/android/systemui/util/wakelock/SettableWakeLock.java
+++ b/packages/SystemUI/src/com/android/systemui/util/wakelock/SettableWakeLock.java
@@ -16,7 +16,7 @@
package com.android.systemui.util.wakelock;
-import com.android.internal.util.Preconditions;
+import java.util.Objects;
public class SettableWakeLock {
@@ -26,7 +26,7 @@
private boolean mAcquired;
public SettableWakeLock(WakeLock inner, String why) {
- Preconditions.checkNotNull(inner, "inner wakelock required");
+ Objects.requireNonNull(inner, "inner wakelock required");
mInner = inner;
mWhy = why;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java
index 0dcd253..e1e7220 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java
@@ -19,7 +19,6 @@
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL;
import static android.service.notification.NotificationListenerService.REASON_CLICK;
-import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.systemui.statusbar.notification.collection.NotifCollection.REASON_UNKNOWN;
import static org.junit.Assert.assertEquals;
@@ -65,6 +64,7 @@
import java.util.Arrays;
import java.util.Map;
+import java.util.Objects;
@SmallTest
@RunWith(AndroidTestingRunner.class)
@@ -99,7 +99,7 @@
// Capture the listener object that the collection registers with the listener service so
// we can simulate listener service events in tests below
verify(mListenerService).addNotificationListener(mListenerCaptor.capture());
- mServiceListener = checkNotNull(mListenerCaptor.getValue());
+ mServiceListener = Objects.requireNonNull(mListenerCaptor.getValue());
mNoMan = new NoManSimulator(mServiceListener);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java
index 6e9c2c8..a8f3638 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java
@@ -16,7 +16,6 @@
package com.android.systemui.statusbar.notification.collection;
-import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.systemui.statusbar.notification.collection.ListDumper.dumpList;
import static org.junit.Assert.assertEquals;
@@ -67,6 +66,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.stream.Collectors;
@SmallTest
@@ -105,7 +105,7 @@
mListBuilder.attach(mNotifCollection);
Mockito.verify(mNotifCollection).setBuildListener(mBuildListenerCaptor.capture());
- mReadyForBuildListener = checkNotNull(mBuildListenerCaptor.getValue());
+ mReadyForBuildListener = Objects.requireNonNull(mBuildListenerCaptor.getValue());
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LightsOutNotifControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LightsOutNotifControllerTest.java
index a024454..3d59d61 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LightsOutNotifControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LightsOutNotifControllerTest.java
@@ -18,8 +18,6 @@
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@@ -50,6 +48,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.Objects;
+
@SmallTest
@RunWith(AndroidTestingRunner.class)
@RunWithLooper
@@ -85,11 +85,11 @@
// Capture the entry listener object so we can simulate events in tests below
verify(mEntryManager).addNotificationEntryListener(mListenerCaptor.capture());
- mEntryListener = checkNotNull(mListenerCaptor.getValue());
+ mEntryListener = Objects.requireNonNull(mListenerCaptor.getValue());
// Capture the callback object so we can simulate callback events in tests below
verify(mCommandQueue).addCallback(mCallbacksCaptor.capture());
- mCallbacks = checkNotNull(mCallbacksCaptor.getValue());
+ mCallbacks = Objects.requireNonNull(mCallbacksCaptor.getValue());
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/sensors/FakeSensorManager.java b/packages/SystemUI/tests/src/com/android/systemui/util/sensors/FakeSensorManager.java
index e15ca1d..27b225e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/sensors/FakeSensorManager.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/sensors/FakeSensorManager.java
@@ -30,14 +30,13 @@
import android.os.SystemClock;
import android.util.ArraySet;
-import com.android.internal.util.Preconditions;
-
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
@@ -113,7 +112,7 @@
@Override
protected void unregisterListenerImpl(SensorEventListener listener, Sensor sensor) {
- Preconditions.checkNotNull(listener);
+ Objects.requireNonNull(listener);
for (FakeGenericSensor s : mSensors) {
if (sensor == null || s.mSensor == sensor) {
s.mListeners.remove(listener);
@@ -125,8 +124,8 @@
protected boolean registerListenerImpl(SensorEventListener listener, Sensor sensor,
int delayUs,
Handler handler, int maxReportLatencyUs, int reservedFlags) {
- Preconditions.checkNotNull(sensor);
- Preconditions.checkNotNull(listener);
+ Objects.requireNonNull(sensor);
+ Objects.requireNonNull(listener);
for (FakeGenericSensor s : mSensors) {
if (s.mSensor == sensor) {
s.mListeners.add(listener);
diff --git a/services/core/java/com/android/server/AppStateTracker.java b/services/core/java/com/android/server/AppStateTracker.java
index 7d5b176..72e170f 100644
--- a/services/core/java/com/android/server/AppStateTracker.java
+++ b/services/core/java/com/android/server/AppStateTracker.java
@@ -63,6 +63,7 @@
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 +417,12 @@
}
mStarted = true;
- mIActivityManager = Preconditions.checkNotNull(injectIActivityManager());
- mActivityManagerInternal = Preconditions.checkNotNull(injectActivityManagerInternal());
- mAppOpsManager = Preconditions.checkNotNull(injectAppOpsManager());
- mAppOpsService = Preconditions.checkNotNull(injectIAppOpsService());
- mPowerManagerInternal = Preconditions.checkNotNull(injectPowerManagerInternal());
- mAppStandbyInternal = Preconditions.checkNotNull(injectAppStandbyInternal());
+ mIActivityManager = Objects.requireNonNull(injectIActivityManager());
+ mActivityManagerInternal = Objects.requireNonNull(injectActivityManagerInternal());
+ mAppOpsManager = Objects.requireNonNull(injectAppOpsManager());
+ mAppOpsService = Objects.requireNonNull(injectIAppOpsService());
+ mPowerManagerInternal = Objects.requireNonNull(injectPowerManagerInternal());
+ mAppStandbyInternal = Objects.requireNonNull(injectAppStandbyInternal());
mFlagsObserver = new FeatureFlagsObserver();
mFlagsObserver.register();
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index bb78ace..deac1e3 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -47,8 +47,6 @@
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 @@
* @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 @@
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 @@
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 @@
@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 @@
@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 @@
@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();
}
diff --git a/services/core/java/com/android/server/ExplicitHealthCheckController.java b/services/core/java/com/android/server/ExplicitHealthCheckController.java
index f7c4aac..77059d9 100644
--- a/services/core/java/com/android/server/ExplicitHealthCheckController.java
+++ b/services/core/java/com/android/server/ExplicitHealthCheckController.java
@@ -47,6 +47,7 @@
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 @@
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);
}
}
diff --git a/services/core/java/com/android/server/IpSecService.java b/services/core/java/com/android/server/IpSecService.java
index a629b3f..c987620 100644
--- a/services/core/java/com/android/server/IpSecService.java
+++ b/services/core/java/com/android/server/IpSecService.java
@@ -25,8 +25,6 @@
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;
@@ -76,6 +74,7 @@
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* A service to manage multiple clients that want to access the IpSec API. The service is
@@ -566,7 +565,7 @@
}
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);
}
@@ -1101,7 +1100,7 @@
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);
@@ -1218,7 +1217,7 @@
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);
@@ -1278,8 +1277,8 @@
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);
@@ -1556,7 +1555,7 @@
"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)) {
case AppOpsManager.MODE_DEFAULT:
mContext.enforceCallingOrSelfPermission(
@@ -1625,12 +1624,12 @@
@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());
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index cad917b..c5f1923 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -23,7 +23,6 @@
import static android.location.LocationManager.PASSIVE_PROVIDER;
import static android.os.PowerManager.locationPowerSaveModeToString;
-import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.internal.util.Preconditions.checkState;
import android.Manifest;
@@ -121,6 +120,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
@@ -821,7 +821,7 @@
@GuardedBy("mLock")
public void attachLocked(AbstractLocationProvider provider) {
- checkNotNull(provider);
+ Objects.requireNonNull(provider);
checkState(mProvider == null);
if (D) {
@@ -1430,7 +1430,7 @@
@Override
public boolean addGnssBatchingCallback(IBatchedLocationCallback callback, String packageName,
String featureId, String listenerIdentifier) {
- Preconditions.checkNotNull(listenerIdentifier);
+ Objects.requireNonNull(listenerIdentifier);
return mGnssManagerService == null ? false : mGnssManagerService.addGnssBatchingCallback(
callback, packageName, featureId, listenerIdentifier);
@@ -2119,7 +2119,7 @@
public void requestLocationUpdates(LocationRequest request, ILocationListener listener,
PendingIntent intent, String packageName, String featureId,
String listenerIdentifier) {
- Preconditions.checkNotNull(listenerIdentifier);
+ Objects.requireNonNull(listenerIdentifier);
synchronized (mLock) {
if (request == null) request = DEFAULT_LOCATION_REQUEST;
@@ -2470,7 +2470,7 @@
@Override
public void requestGeofence(LocationRequest request, Geofence geofence, PendingIntent intent,
String packageName, String featureId, String listenerIdentifier) {
- Preconditions.checkNotNull(listenerIdentifier);
+ Objects.requireNonNull(listenerIdentifier);
if (request == null) request = DEFAULT_LOCATION_REQUEST;
int allowedResolutionLevel = getCallerAllowedResolutionLevel();
@@ -2567,7 +2567,7 @@
@Override
public boolean addGnssMeasurementsListener(IGnssMeasurementsListener listener,
String packageName, String featureId, String listenerIdentifier) {
- Preconditions.checkNotNull(listenerIdentifier);
+ Objects.requireNonNull(listenerIdentifier);
return mGnssManagerService == null ? false
: mGnssManagerService.addGnssMeasurementsListener(listener, packageName, featureId,
@@ -2600,7 +2600,7 @@
@Override
public boolean addGnssNavigationMessageListener(IGnssNavigationMessageListener listener,
String packageName, String featureId, String listenerIdentifier) {
- Preconditions.checkNotNull(listenerIdentifier);
+ Objects.requireNonNull(listenerIdentifier);
return mGnssManagerService == null ? false
: mGnssManagerService.addGnssNavigationMessageListener(listener, packageName,
diff --git a/services/core/java/com/android/server/NativeDaemonConnector.java b/services/core/java/com/android/server/NativeDaemonConnector.java
index ad02aad..eac767f 100644
--- a/services/core/java/com/android/server/NativeDaemonConnector.java
+++ b/services/core/java/com/android/server/NativeDaemonConnector.java
@@ -46,6 +46,7 @@
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 @@
*/
public void setWarnIfHeld(Object warnIfHeld) {
Preconditions.checkState(mWarnIfHeld == null);
- mWarnIfHeld = Preconditions.checkNotNull(warnIfHeld);
+ mWarnIfHeld = Objects.requireNonNull(warnIfHeld);
}
@Override
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index 0d496b6..1f73650 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -109,6 +109,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
/**
* @hide
@@ -456,7 +457,7 @@
@Override
public void registerTetheringStatsProvider(ITetheringStatsProvider provider, String name) {
NetworkStack.checkNetworkStackPermission(mContext);
- Preconditions.checkNotNull(provider);
+ Objects.requireNonNull(provider);
synchronized(mTetheringStatsProviders) {
mTetheringStatsProviders.put(provider, name);
}
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 22fa8ff4..c474f47 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -2102,7 +2102,7 @@
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;
@@ -2115,7 +2115,7 @@
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);
@@ -2128,7 +2128,7 @@
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);
@@ -2534,7 +2534,7 @@
@Override
public String getMountedObbPath(String rawPath) {
- Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
+ Objects.requireNonNull(rawPath, "rawPath cannot be null");
warnOnNotMounted();
@@ -2552,7 +2552,7 @@
@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);
}
@@ -2561,10 +2561,10 @@
@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,
@@ -2578,7 +2578,7 @@
@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) {
diff --git a/services/core/java/com/android/server/SystemServerInitThreadPool.java b/services/core/java/com/android/server/SystemServerInitThreadPool.java
index 5ed94e3..179780d 100644
--- a/services/core/java/com/android/server/SystemServerInitThreadPool.java
+++ b/services/core/java/com/android/server/SystemServerInitThreadPool.java
@@ -28,6 +28,7 @@
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;
@@ -73,7 +74,7 @@
*/
public static @NonNull Future<?> submit(@NonNull Runnable runnable,
@NonNull String description) {
- Preconditions.checkNotNull(description, "description cannot be null");
+ Objects.requireNonNull(description, "description cannot be null");
SystemServerInitThreadPool instance;
synchronized (LOCK) {
diff --git a/services/core/java/com/android/server/TestNetworkService.java b/services/core/java/com/android/server/TestNetworkService.java
index d19d2dd..c27b0da 100644
--- a/services/core/java/com/android/server/TestNetworkService.java
+++ b/services/core/java/com/android/server/TestNetworkService.java
@@ -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.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
/** @hide */
@@ -82,9 +81,9 @@
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 @@
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 @@
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 @@
// 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 @@
@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))) {
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 5996b7d..a372fca0 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -463,7 +463,7 @@
Log.v(TAG, "addAccountExplicitly: " + account + ", caller's uid " + callingUid
+ ", pid " + Binder.getCallingPid());
}
- Preconditions.checkNotNull(account, "account cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
if (!isAccountManagedByCaller(account.type, callingUid, userId)) {
String msg = String.format("uid %s cannot explicitly add accounts of type: %s",
callingUid, account.type);
@@ -544,7 +544,7 @@
@Override
public Map<String, Integer> getPackagesAndVisibilityForAccount(Account account) {
- Preconditions.checkNotNull(account, "account cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
int callingUid = Binder.getCallingUid();
int userId = UserHandle.getCallingUserId();
if (!isAccountManagedByCaller(account.type, callingUid, userId)
@@ -590,8 +590,8 @@
@Override
public int getAccountVisibility(Account account, String packageName) {
- Preconditions.checkNotNull(account, "account cannot be null");
- Preconditions.checkNotNull(packageName, "packageName cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
+ Objects.requireNonNull(packageName, "packageName cannot be null");
int callingUid = Binder.getCallingUid();
int userId = UserHandle.getCallingUserId();
if (!isAccountManagedByCaller(account.type, callingUid, userId)
@@ -659,7 +659,7 @@
*/
private Integer resolveAccountVisibility(Account account, @NonNull String packageName,
UserAccounts accounts) {
- Preconditions.checkNotNull(packageName, "packageName cannot be null");
+ Objects.requireNonNull(packageName, "packageName cannot be null");
int uid = -1;
try {
long identityToken = clearCallingIdentity();
@@ -755,8 +755,8 @@
@Override
public boolean setAccountVisibility(Account account, String packageName, int newVisibility) {
- Preconditions.checkNotNull(account, "account cannot be null");
- Preconditions.checkNotNull(packageName, "packageName cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
+ Objects.requireNonNull(packageName, "packageName cannot be null");
int callingUid = Binder.getCallingUid();
int userId = UserHandle.getCallingUserId();
if (!isAccountManagedByCaller(account.type, callingUid, userId)
@@ -1525,7 +1525,7 @@
+ ", caller's uid " + Binder.getCallingUid()
+ ", pid " + Binder.getCallingPid());
}
- Preconditions.checkNotNull(account, "account cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
int userId = UserHandle.getCallingUserId();
long identityToken = clearCallingIdentity();
try {
@@ -1563,8 +1563,8 @@
account, key, callingUid, Binder.getCallingPid());
Log.v(TAG, msg);
}
- Preconditions.checkNotNull(account, "account cannot be null");
- Preconditions.checkNotNull(key, "key cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
+ Objects.requireNonNull(key, "key cannot be null");
int userId = UserHandle.getCallingUserId();
if (!isAccountManagedByCaller(account.type, callingUid, userId)) {
String msg = String.format(
@@ -1715,7 +1715,7 @@
callingUid);
Log.v(TAG, msg);
}
- Preconditions.checkNotNull(account, "account cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
int userId = UserHandle.getCallingUserId();
if (!isAccountManagedByCaller(account.type, callingUid, userId)) {
String msg = String.format(
@@ -2401,8 +2401,8 @@
@Override
public void invalidateAuthToken(String accountType, String authToken) {
int callerUid = Binder.getCallingUid();
- Preconditions.checkNotNull(accountType, "accountType cannot be null");
- Preconditions.checkNotNull(authToken, "authToken cannot be null");
+ Objects.requireNonNull(accountType, "accountType cannot be null");
+ Objects.requireNonNull(authToken, "authToken cannot be null");
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "invalidateAuthToken: accountType " + accountType
+ ", caller's uid " + callerUid
@@ -2518,8 +2518,8 @@
+ ", caller's uid " + callingUid
+ ", pid " + Binder.getCallingPid());
}
- Preconditions.checkNotNull(account, "account cannot be null");
- Preconditions.checkNotNull(authTokenType, "authTokenType cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
+ Objects.requireNonNull(authTokenType, "authTokenType cannot be null");
int userId = UserHandle.getCallingUserId();
if (!isAccountManagedByCaller(account.type, callingUid, userId)) {
String msg = String.format(
@@ -2551,8 +2551,8 @@
+ ", caller's uid " + callingUid
+ ", pid " + Binder.getCallingPid());
}
- Preconditions.checkNotNull(account, "account cannot be null");
- Preconditions.checkNotNull(authTokenType, "authTokenType cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
+ Objects.requireNonNull(authTokenType, "authTokenType cannot be null");
int userId = UserHandle.getCallingUserId();
if (!isAccountManagedByCaller(account.type, callingUid, userId)) {
String msg = String.format(
@@ -2578,7 +2578,7 @@
+ ", caller's uid " + callingUid
+ ", pid " + Binder.getCallingPid());
}
- Preconditions.checkNotNull(account, "account cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
int userId = UserHandle.getCallingUserId();
if (!isAccountManagedByCaller(account.type, callingUid, userId)) {
String msg = String.format(
@@ -2644,7 +2644,7 @@
+ ", caller's uid " + callingUid
+ ", pid " + Binder.getCallingPid());
}
- Preconditions.checkNotNull(account, "account cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
int userId = UserHandle.getCallingUserId();
if (!isAccountManagedByCaller(account.type, callingUid, userId)) {
String msg = String.format(
@@ -3946,9 +3946,9 @@
if (UserHandle.getAppId(Binder.getCallingUid()) != Process.SYSTEM_UID) {
throw new SecurityException("Can be called only by system UID");
}
- Preconditions.checkNotNull(account, "account cannot be null");
- Preconditions.checkNotNull(packageName, "packageName cannot be null");
- Preconditions.checkNotNull(userHandle, "userHandle cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
+ Objects.requireNonNull(packageName, "packageName cannot be null");
+ Objects.requireNonNull(userHandle, "userHandle cannot be null");
final int userId = userHandle.getIdentifier();
@@ -4022,9 +4022,9 @@
throw new SecurityException("Can be called only by system UID");
}
- Preconditions.checkNotNull(account, "account cannot be null");
- Preconditions.checkNotNull(packageName, "packageName cannot be null");
- Preconditions.checkNotNull(userHandle, "userHandle cannot be null");
+ Objects.requireNonNull(account, "account cannot be null");
+ Objects.requireNonNull(packageName, "packageName cannot be null");
+ Objects.requireNonNull(userHandle, "userHandle cannot be null");
final int userId = userHandle.getIdentifier();
diff --git a/services/core/java/com/android/server/accounts/CryptoHelper.java b/services/core/java/com/android/server/accounts/CryptoHelper.java
index 2ade673..863d6b9 100644
--- a/services/core/java/com/android/server/accounts/CryptoHelper.java
+++ b/services/core/java/com/android/server/accounts/CryptoHelper.java
@@ -10,6 +10,7 @@
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
+import java.util.Objects;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
@@ -54,7 +55,7 @@
@NonNull
/* default */ Bundle encryptBundle(@NonNull Bundle bundle) throws GeneralSecurityException {
- Preconditions.checkNotNull(bundle, "Cannot encrypt null bundle.");
+ Objects.requireNonNull(bundle, "Cannot encrypt null bundle.");
Parcel parcel = Parcel.obtain();
bundle.writeToParcel(parcel, 0);
byte[] clearBytes = parcel.marshall();
@@ -76,7 +77,7 @@
@Nullable
/* default */ Bundle decryptBundle(@NonNull Bundle bundle) throws GeneralSecurityException {
- Preconditions.checkNotNull(bundle, "Cannot decrypt null bundle.");
+ Objects.requireNonNull(bundle, "Cannot decrypt null bundle.");
byte[] iv = bundle.getByteArray(KEY_IV);
byte[] encryptedBytes = bundle.getByteArray(KEY_CIPHER);
byte[] mac = bundle.getByteArray(KEY_MAC);
diff --git a/services/core/java/com/android/server/accounts/TokenCache.java b/services/core/java/com/android/server/accounts/TokenCache.java
index 2af2f38..e38cf5f 100644
--- a/services/core/java/com/android/server/accounts/TokenCache.java
+++ b/services/core/java/com/android/server/accounts/TokenCache.java
@@ -193,7 +193,7 @@
String packageName,
byte[] sigDigest,
long expiryMillis) {
- Preconditions.checkNotNull(account);
+ Objects.requireNonNull(account);
if (token == null || System.currentTimeMillis() > expiryMillis) {
return;
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
index 79fe610..a4c44fa 100644
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -111,6 +111,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -1785,7 +1786,7 @@
}
int runGetCurrentUser(PrintWriter pw) throws RemoteException {
- UserInfo currentUser = Preconditions.checkNotNull(mInterface.getCurrentUser(),
+ UserInfo currentUser = Objects.requireNonNull(mInterface.getCurrentUser(),
"Current user not set");
pw.println(currentUser.id);
return 0;
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index f9730a9..eb1ab38 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -1723,7 +1723,7 @@
}
void registerUserSwitchObserver(IUserSwitchObserver observer, String name) {
- Preconditions.checkNotNull(name, "Observer name cannot be null");
+ Objects.requireNonNull(name, "Observer name cannot be null");
checkCallingPermission(INTERACT_ACROSS_USERS_FULL, "registerUserSwitchObserver");
mUserSwitchObservers.register(observer, name);
}
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 8c9bff9..7ef84bd 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -1417,7 +1417,7 @@
.setOpNames(opNames)
.setFlags(flags)
.build();
- Preconditions.checkNotNull(callback, "callback cannot be null");
+ Objects.requireNonNull(callback, "callback cannot be null");
mContext.enforcePermission(android.Manifest.permission.GET_APP_OPS_STATS,
Binder.getCallingPid(), Binder.getCallingUid(), "getHistoricalOps");
@@ -1442,7 +1442,7 @@
.setOpNames(opNames)
.setFlags(flags)
.build();
- Preconditions.checkNotNull(callback, "callback cannot be null");
+ Objects.requireNonNull(callback, "callback cannot be null");
mContext.enforcePermission(Manifest.permission.MANAGE_APPOPS,
Binder.getCallingPid(), Binder.getCallingUid(), "getHistoricalOps");
@@ -2218,7 +2218,7 @@
@Override
public int checkPackage(int uid, String packageName) {
- Preconditions.checkNotNull(packageName);
+ Objects.requireNonNull(packageName);
try {
verifyAndGetIsPrivileged(uid, packageName);
@@ -2425,7 +2425,7 @@
Preconditions.checkArgument(!ArrayUtils.isEmpty(ops), "Ops cannot be null or empty");
Preconditions.checkArrayElementsInRange(ops, 0, AppOpsManager._NUM_OP - 1,
"Invalid op code in: " + Arrays.toString(ops));
- Preconditions.checkNotNull(callback, "Callback cannot be null");
+ Objects.requireNonNull(callback, "Callback cannot be null");
synchronized (this) {
SparseArray<NotedCallback> callbacks = mNotedWatchers.get(callback.asBinder());
if (callbacks == null) {
@@ -2442,7 +2442,7 @@
@Override
public void stopWatchingNoted(IAppOpsNotedCallback callback) {
- Preconditions.checkNotNull(callback, "Callback cannot be null");
+ Objects.requireNonNull(callback, "Callback cannot be null");
synchronized (this) {
final SparseArray<NotedCallback> notedCallbacks =
mNotedWatchers.remove(callback.asBinder());
@@ -2459,7 +2459,7 @@
@Override
public void noteAsyncOp(String callingPackageName, int uid, String packageName, int opCode,
String featureId, String message) {
- Preconditions.checkNotNull(message);
+ Objects.requireNonNull(message);
verifyAndGetIsPrivileged(uid, packageName);
verifyIncomingUid(uid);
@@ -2528,8 +2528,8 @@
@Override
public void startWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback) {
- Preconditions.checkNotNull(packageName);
- Preconditions.checkNotNull(callback);
+ Objects.requireNonNull(packageName);
+ Objects.requireNonNull(callback);
int uid = Binder.getCallingUid();
Pair<String, Integer> key = getAsyncNotedOpsKey(packageName, uid);
@@ -2558,8 +2558,8 @@
@Override
public void stopWatchingAsyncNoted(String packageName, IAppOpsAsyncNotedCallback callback) {
- Preconditions.checkNotNull(packageName);
- Preconditions.checkNotNull(callback);
+ Objects.requireNonNull(packageName);
+ Objects.requireNonNull(callback);
int uid = Binder.getCallingUid();
Pair<String, Integer> key = getAsyncNotedOpsKey(packageName, uid);
@@ -2579,7 +2579,7 @@
@Override
public List<AsyncNotedAppOp> extractAsyncOps(String packageName) {
- Preconditions.checkNotNull(packageName);
+ Objects.requireNonNull(packageName);
int uid = Binder.getCallingUid();
@@ -4708,8 +4708,8 @@
@Override
public void setUserRestrictions(Bundle restrictions, IBinder token, int userHandle) {
checkSystemUid("setUserRestrictions");
- Preconditions.checkNotNull(restrictions);
- Preconditions.checkNotNull(token);
+ Objects.requireNonNull(restrictions);
+ Objects.requireNonNull(token);
for (int i = 0; i < AppOpsManager._NUM_OP; i++) {
String restriction = AppOpsManager.opToRestriction(i);
if (restriction != null) {
@@ -4736,7 +4736,7 @@
}
}
verifyIncomingOp(code);
- Preconditions.checkNotNull(token);
+ Objects.requireNonNull(token);
setUserRestrictionNoCheck(code, restricted, token, userHandle, exceptionPackages);
}
diff --git a/services/core/java/com/android/server/attention/AttentionManagerService.java b/services/core/java/com/android/server/attention/AttentionManagerService.java
index fc67e24..5ac5b29 100644
--- a/services/core/java/com/android/server/attention/AttentionManagerService.java
+++ b/services/core/java/com/android/server/attention/AttentionManagerService.java
@@ -67,6 +67,7 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.Objects;
/**
* An attention service implementation that runs in System Server process.
@@ -120,7 +121,7 @@
AttentionManagerService(Context context, PowerManager powerManager, Object lock,
AttentionHandler handler) {
super(context);
- mContext = Preconditions.checkNotNull(context);
+ mContext = Objects.requireNonNull(context);
mPowerManager = powerManager;
mLock = lock;
mAttentionHandler = handler;
@@ -200,7 +201,7 @@
*/
@VisibleForTesting
boolean checkAttention(long timeout, AttentionCallbackInternal callbackInternal) {
- Preconditions.checkNotNull(callbackInternal);
+ Objects.requireNonNull(callbackInternal);
if (!isAttentionServiceSupported()) {
Slog.w(LOG_TAG, "Trying to call checkAttention() on an unsupported device.");
@@ -543,9 +544,9 @@
UserState(int userId, Context context, Object lock, Handler handler,
ComponentName componentName) {
mUserId = userId;
- mContext = Preconditions.checkNotNull(context);
- mLock = Preconditions.checkNotNull(lock);
- mComponentName = Preconditions.checkNotNull(componentName);
+ mContext = Objects.requireNonNull(context);
+ mLock = Objects.requireNonNull(lock);
+ mComponentName = Objects.requireNonNull(componentName);
mAttentionHandler = handler;
}
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 114aac9..bc4dc8f 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -2196,7 +2196,7 @@
public void setVolumeIndexForAttributes(@NonNull AudioAttributes attr, int index, int flags,
String callingPackage) {
enforceModifyAudioRoutingPermission();
- Preconditions.checkNotNull(attr, "attr must not be null");
+ Objects.requireNonNull(attr, "attr must not be null");
// @todo not hold the caller context, post message
int stream = AudioProductStrategy.getLegacyStreamTypeForStrategyWithAudioAttributes(attr);
final int device = getDeviceForStream(stream);
@@ -2231,7 +2231,7 @@
/** @see AudioManager#getVolumeIndexForAttributes(attr) */
public int getVolumeIndexForAttributes(@NonNull AudioAttributes attr) {
enforceModifyAudioRoutingPermission();
- Preconditions.checkNotNull(attr, "attr must not be null");
+ Objects.requireNonNull(attr, "attr must not be null");
int stream = AudioProductStrategy.getLegacyStreamTypeForStrategyWithAudioAttributes(attr);
final int device = getDeviceForStream(stream);
@@ -2241,14 +2241,14 @@
/** @see AudioManager#getMaxVolumeIndexForAttributes(attr) */
public int getMaxVolumeIndexForAttributes(@NonNull AudioAttributes attr) {
enforceModifyAudioRoutingPermission();
- Preconditions.checkNotNull(attr, "attr must not be null");
+ Objects.requireNonNull(attr, "attr must not be null");
return AudioSystem.getMaxVolumeIndexForAttributes(attr);
}
/** @see AudioManager#getMinVolumeIndexForAttributes(attr) */
public int getMinVolumeIndexForAttributes(@NonNull AudioAttributes attr) {
enforceModifyAudioRoutingPermission();
- Preconditions.checkNotNull(attr, "attr must not be null");
+ Objects.requireNonNull(attr, "attr must not be null");
return AudioSystem.getMinVolumeIndexForAttributes(attr);
}
@@ -2510,7 +2510,7 @@
private int getVolumeGroupIdForAttributes(@NonNull AudioAttributes attributes) {
- Preconditions.checkNotNull(attributes, "attributes must not be null");
+ Objects.requireNonNull(attributes, "attributes must not be null");
int volumeGroupId = getVolumeGroupIdForAttributesInt(attributes);
if (volumeGroupId != AudioVolumeGroup.DEFAULT_VOLUME_GROUP) {
return volumeGroupId;
@@ -2521,7 +2521,7 @@
}
private int getVolumeGroupIdForAttributesInt(@NonNull AudioAttributes attributes) {
- Preconditions.checkNotNull(attributes, "attributes must not be null");
+ Objects.requireNonNull(attributes, "attributes must not be null");
for (final AudioProductStrategy productStrategy :
AudioProductStrategy.getAudioProductStrategies()) {
int volumeGroupId = productStrategy.getVolumeGroupIdForAudioAttributes(attributes);
diff --git a/services/core/java/com/android/server/display/BrightnessMappingStrategy.java b/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
index ff0b015..28f67fe 100644
--- a/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
+++ b/services/core/java/com/android/server/display/BrightnessMappingStrategy.java
@@ -34,6 +34,7 @@
import java.io.PrintWriter;
import java.util.Arrays;
+import java.util.Objects;
/**
* A utility to map from an ambient brightness to a display's "backlight" brightness based on the
@@ -702,7 +703,7 @@
"Nits and backlight arrays must not be empty!");
Preconditions.checkArgument(nits.length == backlight.length,
"Nits and backlight arrays must be the same length!");
- Preconditions.checkNotNull(config);
+ Objects.requireNonNull(config);
Preconditions.checkArrayElementsInRange(nits, 0, Float.MAX_VALUE, "nits");
Preconditions.checkArrayElementsInRange(backlight,
PowerManager.BRIGHTNESS_OFF, PowerManager.BRIGHTNESS_ON, "backlight");
diff --git a/services/core/java/com/android/server/display/whitebalance/AmbientSensor.java b/services/core/java/com/android/server/display/whitebalance/AmbientSensor.java
index 1707a62..75d00ff 100644
--- a/services/core/java/com/android/server/display/whitebalance/AmbientSensor.java
+++ b/services/core/java/com/android/server/display/whitebalance/AmbientSensor.java
@@ -29,6 +29,7 @@
import com.android.server.display.utils.History;
import java.io.PrintWriter;
+import java.util.Objects;
/**
* The DisplayWhiteBalanceController uses the AmbientSensor to detect changes in the ambient
@@ -139,8 +140,8 @@
private static void validateArguments(Handler handler, SensorManager sensorManager, int rate) {
- Preconditions.checkNotNull(handler, "handler cannot be null");
- Preconditions.checkNotNull(sensorManager, "sensorManager cannot be null");
+ Objects.requireNonNull(handler, "handler cannot be null");
+ Objects.requireNonNull(sensorManager, "sensorManager cannot be null");
if (rate <= 0) {
throw new IllegalArgumentException("rate must be positive");
}
diff --git a/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java b/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java
index 88a7077..d64fcbc 100644
--- a/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java
+++ b/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java
@@ -28,6 +28,7 @@
import com.android.server.display.utils.History;
import java.io.PrintWriter;
+import java.util.Objects;
/**
* The DisplayWhiteBalanceController drives display white-balance (automatically correcting the
@@ -475,13 +476,13 @@
AmbientSensor.AmbientColorTemperatureSensor colorTemperatureSensor,
AmbientFilter colorTemperatureFilter,
DisplayWhiteBalanceThrottler throttler) {
- Preconditions.checkNotNull(brightnessSensor, "brightnessSensor must not be null");
- Preconditions.checkNotNull(brightnessFilter, "brightnessFilter must not be null");
- Preconditions.checkNotNull(colorTemperatureSensor,
+ Objects.requireNonNull(brightnessSensor, "brightnessSensor must not be null");
+ Objects.requireNonNull(brightnessFilter, "brightnessFilter must not be null");
+ Objects.requireNonNull(colorTemperatureSensor,
"colorTemperatureSensor must not be null");
- Preconditions.checkNotNull(colorTemperatureFilter,
+ Objects.requireNonNull(colorTemperatureFilter,
"colorTemperatureFilter must not be null");
- Preconditions.checkNotNull(throttler, "throttler cannot be null");
+ Objects.requireNonNull(throttler, "throttler cannot be null");
}
private boolean enable() {
diff --git a/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceSettings.java b/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceSettings.java
index 6e78894..0efb749 100644
--- a/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceSettings.java
+++ b/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceSettings.java
@@ -30,6 +30,7 @@
import com.android.server.display.whitebalance.DisplayWhiteBalanceController.Callbacks;
import java.io.PrintWriter;
+import java.util.Objects;
/**
* The DisplayWhiteBalanceSettings holds the state of all the settings related to
@@ -144,8 +145,8 @@
}
private void validateArguments(Context context, Handler handler) {
- Preconditions.checkNotNull(context, "context must not be null");
- Preconditions.checkNotNull(handler, "handler must not be null");
+ Objects.requireNonNull(context, "context must not be null");
+ Objects.requireNonNull(handler, "handler must not be null");
}
private void setEnabled(boolean enabled) {
diff --git a/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java b/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java
index 33e12c6..b1639a9 100644
--- a/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java
+++ b/services/core/java/com/android/server/integrity/AppIntegrityManagerServiceImpl.java
@@ -385,6 +385,9 @@
String packageName = getPackageNameNormalized(packageAndCert[0]);
String cert = packageAndCert[1];
packageCertMap.put(packageName, cert);
+ } else if (packageAndCert.length == 1
+ && packageAndCert[0].equals(ADB_INSTALLER)) {
+ packageCertMap.put(ADB_INSTALLER, INSTALLER_CERT_NOT_APPLICABLE);
}
}
}
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
}
diff --git a/services/core/java/com/android/server/policy/SoftRestrictedPermissionPolicy.java b/services/core/java/com/android/server/policy/SoftRestrictedPermissionPolicy.java
index f3a6018..b0f22e4 100644
--- a/services/core/java/com/android/server/policy/SoftRestrictedPermissionPolicy.java
+++ b/services/core/java/com/android/server/policy/SoftRestrictedPermissionPolicy.java
@@ -145,8 +145,7 @@
}
@Override
public boolean mayAllowExtraAppOp() {
- return !shouldApplyRestriction && hasRequestedLegacyExternalStorage
- && targetSDK <= Build.VERSION_CODES.Q;
+ return !shouldApplyRestriction && hasRequestedLegacyExternalStorage;
}
@Override
public boolean mayDenyExtraAppOpIfGranted() {
diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySaverController.java b/services/core/java/com/android/server/power/batterysaver/BatterySaverController.java
index f0e4625..4142e6f 100644
--- a/services/core/java/com/android/server/power/batterysaver/BatterySaverController.java
+++ b/services/core/java/com/android/server/power/batterysaver/BatterySaverController.java
@@ -49,6 +49,7 @@
import com.android.server.power.batterysaver.BatterySavingStats.InteractiveState;
import java.util.ArrayList;
+import java.util.Objects;
/**
* Responsible for battery saver mode transition logic.
@@ -237,7 +238,7 @@
private PowerManager getPowerManager() {
if (mPowerManager == null) {
mPowerManager =
- Preconditions.checkNotNull(mContext.getSystemService(PowerManager.class));
+ Objects.requireNonNull(mContext.getSystemService(PowerManager.class));
}
return mPowerManager;
}
diff --git a/services/core/java/com/android/server/rollback/RollbackPackageHealthObserver.java b/services/core/java/com/android/server/rollback/RollbackPackageHealthObserver.java
index bb09584..162a695 100644
--- a/services/core/java/com/android/server/rollback/RollbackPackageHealthObserver.java
+++ b/services/core/java/com/android/server/rollback/RollbackPackageHealthObserver.java
@@ -120,9 +120,7 @@
RollbackInfo rollback = getAvailableRollback(failedPackage);
if (rollback == null) {
- Slog.w(TAG, "Expected rollback but no valid rollback found for package: [ "
- + failedPackage.getPackageName() + "] with versionCode: ["
- + failedPackage.getVersionCode() + "]");
+ Slog.w(TAG, "Expected rollback but no valid rollback found for " + failedPackage);
return false;
}
rollbackPackage(rollback, failedPackage, rollbackReason);
@@ -212,11 +210,7 @@
RollbackManager rollbackManager = mContext.getSystemService(RollbackManager.class);
for (RollbackInfo rollback : rollbackManager.getAvailableRollbacks()) {
for (PackageRollbackInfo packageRollback : rollback.getPackages()) {
- boolean hasFailedPackage = packageRollback.getPackageName().equals(
- failedPackage.getPackageName())
- && packageRollback.getVersionRolledBackFrom().getVersionCode()
- == failedPackage.getVersionCode();
- if (hasFailedPackage) {
+ if (packageRollback.getVersionRolledBackFrom().equals(failedPackage)) {
return rollback;
}
}
@@ -361,15 +355,6 @@
}
}
- private VersionedPackage getVersionedPackage(String packageName) {
- try {
- return new VersionedPackage(packageName, mContext.getPackageManager().getPackageInfo(
- packageName, 0 /* flags */).getLongVersionCode());
- } catch (PackageManager.NameNotFoundException e) {
- return null;
- }
- }
-
/**
* Rolls back the session that owns {@code failedPackage}
*
@@ -432,14 +417,8 @@
List<RollbackInfo> rollbacks = rollbackManager.getAvailableRollbacks();
for (RollbackInfo rollback : rollbacks) {
- String samplePackageName = rollback.getPackages().get(0).getPackageName();
- VersionedPackage sampleVersionedPackage = getVersionedPackage(samplePackageName);
- if (sampleVersionedPackage == null) {
- Slog.e(TAG, "Failed to rollback " + samplePackageName);
- continue;
- }
- rollbackPackage(rollback, sampleVersionedPackage,
- PackageWatchdog.FAILURE_REASON_NATIVE_CRASH);
+ VersionedPackage sample = rollback.getPackages().get(0).getVersionRolledBackFrom();
+ rollbackPackage(rollback, sample, PackageWatchdog.FAILURE_REASON_NATIVE_CRASH);
}
}
diff --git a/services/core/java/com/android/server/security/FileIntegrityService.java b/services/core/java/com/android/server/security/FileIntegrityService.java
index 0bbb179..e90c02a 100644
--- a/services/core/java/com/android/server/security/FileIntegrityService.java
+++ b/services/core/java/com/android/server/security/FileIntegrityService.java
@@ -59,7 +59,7 @@
}
@Override
- public boolean isAppSourceCertificateTrusted(byte[] certificateBytes) {
+ public boolean isAppSourceCertificateTrusted(@Nullable byte[] certificateBytes) {
enforceAnyCallingPermissions(
android.Manifest.permission.REQUEST_INSTALL_PACKAGES,
android.Manifest.permission.INSTALL_PACKAGES);
@@ -67,7 +67,10 @@
if (!isApkVeritySupported()) {
return false;
}
-
+ if (certificateBytes == null) {
+ Slog.w(TAG, "Received a null certificate");
+ return false;
+ }
return mTrustedCertificates.contains(toCertificate(certificateBytes));
} catch (CertificateException e) {
Slog.e(TAG, "Failed to convert the certificate: " + e);
@@ -122,7 +125,12 @@
}
for (File cert : files) {
- collectCertificate(Files.readAllBytes(cert.toPath()));
+ byte[] certificateBytes = Files.readAllBytes(cert.toPath());
+ if (certificateBytes == null) {
+ Slog.w(TAG, "The certificate file is empty, ignoring " + cert);
+ continue;
+ }
+ collectCertificate(certificateBytes);
}
} catch (IOException e) {
Slog.wtf(TAG, "Failed to load fs-verity certificate from " + path, e);
@@ -146,10 +154,10 @@
* Tries to convert {@code bytes} into an X.509 certificate and store in memory.
* Errors need to be surpressed in order fo the next certificates to still be collected.
*/
- private void collectCertificate(@Nullable byte[] bytes) {
+ private void collectCertificate(@NonNull byte[] bytes) {
try {
mTrustedCertificates.add(toCertificate(bytes));
- } catch (CertificateException | AssertionError e) {
+ } catch (CertificateException e) {
Slog.e(TAG, "Invalid certificate, ignored: " + e);
}
}
@@ -159,7 +167,7 @@
* the rest. The rational is to make it harder to smuggle.
*/
@NonNull
- private static X509Certificate toCertificate(@Nullable byte[] bytes)
+ private static X509Certificate toCertificate(@NonNull byte[] bytes)
throws CertificateException {
Certificate certificate = sCertFactory.generateCertificate(new ByteArrayInputStream(bytes));
if (!(certificate instanceof X509Certificate)) {
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index ac1dbc4..6c3b580 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -296,6 +296,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
/**
@@ -6164,7 +6165,7 @@
final class LocalService extends ActivityTaskManagerInternal {
@Override
public SleepToken acquireSleepToken(String tag, int displayId) {
- Preconditions.checkNotNull(tag);
+ Objects.requireNonNull(tag);
return ActivityTaskManagerService.this.acquireSleepToken(tag, displayId);
}
@@ -6221,7 +6222,7 @@
@Override
public int startActivitiesAsPackage(String packageName, int userId, Intent[] intents,
Bundle bOptions) {
- Preconditions.checkNotNull(intents, "intents");
+ Objects.requireNonNull(intents, "intents");
final String[] resolvedTypes = new String[intents.length];
// UID of the package on user userId.
diff --git a/services/core/java/com/android/server/wm/DragDropController.java b/services/core/java/com/android/server/wm/DragDropController.java
index d5f403f..999aab9 100644
--- a/services/core/java/com/android/server/wm/DragDropController.java
+++ b/services/core/java/com/android/server/wm/DragDropController.java
@@ -37,6 +37,7 @@
import com.android.internal.util.Preconditions;
import com.android.server.wm.WindowManagerInternal.IDragDropCallback;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
/**
@@ -74,7 +75,7 @@
}
void registerCallback(IDragDropCallback callback) {
- Preconditions.checkNotNull(callback);
+ Objects.requireNonNull(callback);
mCallback.set(callback);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerConstants.java b/services/core/java/com/android/server/wm/WindowManagerConstants.java
index 74d5c04..b0c5dbc 100644
--- a/services/core/java/com/android/server/wm/WindowManagerConstants.java
+++ b/services/core/java/com/android/server/wm/WindowManagerConstants.java
@@ -19,8 +19,6 @@
import static android.provider.AndroidDeviceConfig.KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE;
import static android.provider.AndroidDeviceConfig.KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import android.provider.AndroidDeviceConfig;
import android.provider.DeviceConfig;
@@ -28,6 +26,7 @@
import com.android.server.wm.utils.DeviceConfigInterface;
import java.io.PrintWriter;
+import java.util.Objects;
import java.util.concurrent.Executor;
/**
@@ -74,8 +73,8 @@
WindowManagerConstants(WindowManagerGlobalLock globalLock,
Runnable updateSystemGestureExclusionCallback,
DeviceConfigInterface deviceConfig) {
- mGlobalLock = checkNotNull(globalLock);
- mUpdateSystemGestureExclusionCallback = checkNotNull(updateSystemGestureExclusionCallback);
+ mGlobalLock = Objects.requireNonNull(globalLock);
+ mUpdateSystemGestureExclusionCallback = Objects.requireNonNull(updateSystemGestureExclusionCallback);
mDeviceConfig = deviceConfig;
mListenerAndroid = this::onAndroidPropertiesChanged;
mListenerWindowManager = this::onWindowPropertiesChanged;
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 53c5ebd..9c554d9 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -296,6 +296,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -2864,7 +2865,7 @@
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires DISABLE_KEYGUARD permission");
}
- Preconditions.checkNotNull(token, "token is null");
+ Objects.requireNonNull(token, "token is null");
final int callingUid = Binder.getCallingUid();
final long origIdentity = Binder.clearCallingIdentity();
try {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 1536816..272edf7 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -303,6 +303,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -2266,23 +2267,23 @@
@VisibleForTesting
DevicePolicyManagerService(Injector injector) {
mInjector = injector;
- mContext = Preconditions.checkNotNull(injector.mContext);
- mHandler = new Handler(Preconditions.checkNotNull(injector.getMyLooper()));
+ mContext = Objects.requireNonNull(injector.mContext);
+ mHandler = new Handler(Objects.requireNonNull(injector.getMyLooper()));
mConstantsObserver = new DevicePolicyConstantsObserver(mHandler);
mConstantsObserver.register();
mConstants = loadConstants();
- mOwners = Preconditions.checkNotNull(injector.newOwners());
+ mOwners = Objects.requireNonNull(injector.newOwners());
- mUserManager = Preconditions.checkNotNull(injector.getUserManager());
- mUserManagerInternal = Preconditions.checkNotNull(injector.getUserManagerInternal());
- mUsageStatsManagerInternal = Preconditions.checkNotNull(
+ mUserManager = Objects.requireNonNull(injector.getUserManager());
+ mUserManagerInternal = Objects.requireNonNull(injector.getUserManagerInternal());
+ mUsageStatsManagerInternal = Objects.requireNonNull(
injector.getUsageStatsManagerInternal());
- mIPackageManager = Preconditions.checkNotNull(injector.getIPackageManager());
- mIPlatformCompat = Preconditions.checkNotNull(injector.getIPlatformCompat());
- mIPermissionManager = Preconditions.checkNotNull(injector.getIPermissionManager());
- mTelephonyManager = Preconditions.checkNotNull(injector.getTelephonyManager());
+ mIPackageManager = Objects.requireNonNull(injector.getIPackageManager());
+ mIPlatformCompat = Objects.requireNonNull(injector.getIPlatformCompat());
+ mIPermissionManager = Objects.requireNonNull(injector.getIPermissionManager());
+ mTelephonyManager = Objects.requireNonNull(injector.getTelephonyManager());
mLocalService = new LocalService();
mLockPatternUtils = injector.newLockPatternUtils();
@@ -4047,7 +4048,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(adminReceiver, "ComponentName is null");
+ Objects.requireNonNull(adminReceiver, "ComponentName is null");
enforceShell("forceRemoveActiveAdmin");
mInjector.binderWithCleanCallingIdentity(() -> {
synchronized (getLockObject()) {
@@ -4164,7 +4165,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
validateQualityConstant(quality);
final int userId = mInjector.userHandleGetCallingUserId();
@@ -4377,7 +4378,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(
@@ -4419,7 +4420,7 @@
if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(
@@ -4451,7 +4452,7 @@
if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
Preconditions.checkArgumentNonnegative(timeout, "Timeout must be >= 0 ms");
final int userHandle = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
@@ -4633,7 +4634,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
final ActiveAdmin ap = getActiveAdminForCallerLocked(
@@ -4663,7 +4664,7 @@
@Override
public void setPasswordMinimumLowerCase(ComponentName who, int length, boolean parent) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(
@@ -4696,7 +4697,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(
@@ -4728,7 +4729,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(
@@ -4760,7 +4761,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(
@@ -4792,7 +4793,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(
@@ -5019,7 +5020,7 @@
if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
// This API can only be called by an active device admin,
@@ -5259,7 +5260,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
final ActiveAdmin ap = getActiveAdminForCallerLocked(
@@ -5360,7 +5361,7 @@
if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
Preconditions.checkArgument(timeoutMs >= 0, "Timeout must not be a negative number.");
// timeoutMs with value 0 means that the admin doesn't participate
// timeoutMs is clamped to the interval in case the internal constants change in the future
@@ -6108,7 +6109,7 @@
@Override
public void setDelegatedScopes(ComponentName who, String delegatePackage,
List<String> scopeList) throws SecurityException {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
Preconditions.checkStringNotEmpty(delegatePackage, "Delegate package is null or empty");
Preconditions.checkCollectionElementsNotNull(scopeList, "Scopes");
// Remove possible duplicates.
@@ -6206,7 +6207,7 @@
@NonNull
public List<String> getDelegatedScopes(ComponentName who,
String delegatePackage) throws SecurityException {
- Preconditions.checkNotNull(delegatePackage, "Delegate package is null");
+ Objects.requireNonNull(delegatePackage, "Delegate package is null");
// Retrieve the user ID of the calling process.
final int callingUid = mInjector.binderGetCallingUid();
@@ -6246,8 +6247,8 @@
@NonNull
public List<String> getDelegatePackages(ComponentName who, String scope)
throws SecurityException {
- Preconditions.checkNotNull(who, "ComponentName is null");
- Preconditions.checkNotNull(scope, "Scope is null");
+ Objects.requireNonNull(who, "ComponentName is null");
+ Objects.requireNonNull(scope, "Scope is null");
if (!Arrays.asList(DELEGATIONS).contains(scope)) {
throw new IllegalArgumentException("Unexpected delegation scope: " + scope);
}
@@ -6329,7 +6330,7 @@
* @return {@code true} if the calling process is a delegate of {@code scope}.
*/
private boolean isCallerDelegate(String callerPackage, int callerUid, String scope) {
- Preconditions.checkNotNull(callerPackage, "callerPackage is null");
+ Objects.requireNonNull(callerPackage, "callerPackage is null");
if (!Arrays.asList(DELEGATIONS).contains(scope)) {
throw new IllegalArgumentException("Unexpected delegation scope: " + scope);
}
@@ -6410,7 +6411,7 @@
*/
private void setDelegatedScopePreO(ComponentName who,
String delegatePackage, String scope) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
@@ -6938,7 +6939,7 @@
return null;
}
synchronized (getLockObject()) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
// Only check if system user has set global proxy. We don't allow other users to set it.
DevicePolicyData policy = getUserData(UserHandle.USER_SYSTEM);
@@ -7066,7 +7067,7 @@
if (!mHasFeature) {
return DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = UserHandle.getCallingUserId();
synchronized (getLockObject()) {
// Check for permissions
@@ -7220,7 +7221,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = UserHandle.getCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(who,
@@ -7287,7 +7288,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = UserHandle.getCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
@@ -7347,7 +7348,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
// TODO (b/145286957) Refactor security checks
enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned();
@@ -7369,7 +7370,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned();
return mInjector.settingsGlobalGetInt(Global.AUTO_TIME, 0) > 0;
@@ -7383,7 +7384,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
// TODO (b/145286957) Refactor security checks
enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned();
@@ -7405,7 +7406,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned();
return mInjector.settingsGlobalGetInt(Global.AUTO_TIME_ZONE, 0) > 0;
@@ -7416,7 +7417,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
// Allow setting this policy to true only if there is a split system user.
if (forceEphemeralUsers && !mInjector.userManagerIsSplitSystemUser()) {
throw new UnsupportedOperationException(
@@ -7443,7 +7444,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
final ActiveAdmin deviceOwner =
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
@@ -7472,7 +7473,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
// TODO: If an unaffiliated user is removed, the admin will be able to request a bugreport
// which could still contain data related to that user. Should we disallow that, e.g. until
@@ -7709,7 +7710,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
int userHandle = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(who,
@@ -7779,7 +7780,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = mInjector.userHandleGetCallingUserId();
if (isManagedProfile(userHandle)) {
if (parent) {
@@ -7867,7 +7868,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(packageList, "packageList is null");
+ Objects.requireNonNull(packageList, "packageList is null");
final int userHandle = UserHandle.getCallingUserId();
synchronized (getLockObject()) {
// Ensure the caller is a DO or a keep uninstalled packages delegate.
@@ -8104,7 +8105,7 @@
@Override
public void clearDeviceOwner(String packageName) {
- Preconditions.checkNotNull(packageName, "packageName is null");
+ Objects.requireNonNull(packageName, "packageName is null");
final int callingUid = mInjector.binderGetCallingUid();
try {
int uid = mInjector.getPackageManager().getPackageUidAsUser(packageName,
@@ -8259,7 +8260,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
enforceNotManagedProfile(userId, "clear profile owner");
@@ -8300,7 +8301,7 @@
@Override
public void setDeviceOwnerLockScreenInfo(ComponentName who, CharSequence info) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
if (!mHasFeature) {
return;
}
@@ -8470,7 +8471,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
// Check if this is the profile owner who is calling
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -8497,7 +8498,7 @@
@Override
public void setProfileName(ComponentName who, String profileName) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceProfileOrDeviceOwner(who);
final int userId = UserHandle.getCallingUserId();
@@ -9090,7 +9091,7 @@
@Override
public void addPersistentPreferredActivity(ComponentName who, IntentFilter filter,
ComponentName activity) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = UserHandle.getCallingUserId();
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -9116,7 +9117,7 @@
@Override
public void clearPackagePersistentPreferredActivities(ComponentName who, String packageName) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = UserHandle.getCallingUserId();
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -9135,7 +9136,7 @@
@Override
public void setDefaultSmsApplication(ComponentName admin, String packageName) {
- Preconditions.checkNotNull(admin, "ComponentName is null");
+ Objects.requireNonNull(admin, "ComponentName is null");
enforceDeviceOwner(admin);
mInjector.binderWithCleanCallingIdentity(() ->
SmsApplication.setDefaultApplication(packageName, mContext));
@@ -9190,8 +9191,8 @@
if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) {
return;
}
- Preconditions.checkNotNull(admin, "admin is null");
- Preconditions.checkNotNull(agent, "agent is null");
+ Objects.requireNonNull(admin, "admin is null");
+ Objects.requireNonNull(agent, "agent is null");
final int userHandle = UserHandle.getCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(admin,
@@ -9207,7 +9208,7 @@
if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) {
return null;
}
- Preconditions.checkNotNull(agent, "agent null");
+ Objects.requireNonNull(agent, "agent null");
enforceFullCrossUsersPermission(userHandle);
synchronized (getLockObject()) {
@@ -9259,7 +9260,7 @@
@Override
public void setRestrictionsProvider(ComponentName who, ComponentName permissionProvider) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -9281,7 +9282,7 @@
@Override
public void addCrossProfileIntentFilter(ComponentName who, IntentFilter filter, int flags) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
int callingUserId = UserHandle.getCallingUserId();
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -9330,7 +9331,7 @@
@Override
public void clearCrossProfileIntentFilters(ComponentName who) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
int callingUserId = UserHandle.getCallingUserId();
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -9407,7 +9408,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
if (packageList != null) {
int userId = UserHandle.getCallingUserId();
@@ -9460,7 +9461,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
@@ -9536,7 +9537,7 @@
if (!mHasFeature) {
return true;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
Preconditions.checkStringNotEmpty(packageName, "packageName is null");
enforceSystemCaller("query if an accessibility service is disabled by admin");
@@ -9587,7 +9588,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int callingUserId = mInjector.userHandleGetCallingUserId();
if (packageList != null) {
List<InputMethodInfo> enabledImes = InputMethodManagerInternal.get()
@@ -9627,7 +9628,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
@@ -9681,7 +9682,7 @@
if (!mHasFeature) {
return true;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
Preconditions.checkStringNotEmpty(packageName, "packageName is null");
enforceSystemCaller("query if an input method is disabled by admin");
@@ -9704,7 +9705,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int callingUserId = mInjector.userHandleGetCallingUserId();
if (!isManagedProfile(callingUserId)) {
@@ -9725,7 +9726,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(
@@ -9787,8 +9788,8 @@
@Override
public UserHandle createAndManageUser(ComponentName admin, String name,
ComponentName profileOwner, PersistableBundle adminExtras, int flags) {
- Preconditions.checkNotNull(admin, "admin is null");
- Preconditions.checkNotNull(profileOwner, "profileOwner is null");
+ Objects.requireNonNull(admin, "admin is null");
+ Objects.requireNonNull(profileOwner, "profileOwner is null");
if (!admin.getPackageName().equals(profileOwner.getPackageName())) {
throw new IllegalArgumentException("profileOwner " + profileOwner + " and admin "
+ admin + " are not in the same package");
@@ -9919,8 +9920,8 @@
@Override
public boolean removeUser(ComponentName who, UserHandle userHandle) {
- Preconditions.checkNotNull(who, "ComponentName is null");
- Preconditions.checkNotNull(userHandle, "UserHandle is null");
+ Objects.requireNonNull(who, "ComponentName is null");
+ Objects.requireNonNull(userHandle, "UserHandle is null");
enforceDeviceOwner(who);
final int callingUserId = mInjector.userHandleGetCallingUserId();
@@ -9953,7 +9954,7 @@
@Override
public boolean switchUser(ComponentName who, UserHandle userHandle) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
@@ -9976,8 +9977,8 @@
@Override
public int startUserInBackground(ComponentName who, UserHandle userHandle) {
- Preconditions.checkNotNull(who, "ComponentName is null");
- Preconditions.checkNotNull(userHandle, "UserHandle is null");
+ Objects.requireNonNull(who, "ComponentName is null");
+ Objects.requireNonNull(userHandle, "UserHandle is null");
enforceDeviceOwner(who);
final int userId = userHandle.getIdentifier();
@@ -10008,8 +10009,8 @@
@Override
public int stopUser(ComponentName who, UserHandle userHandle) {
- Preconditions.checkNotNull(who, "ComponentName is null");
- Preconditions.checkNotNull(userHandle, "UserHandle is null");
+ Objects.requireNonNull(who, "ComponentName is null");
+ Objects.requireNonNull(userHandle, "UserHandle is null");
enforceDeviceOwner(who);
final int userId = userHandle.getIdentifier();
@@ -10023,7 +10024,7 @@
@Override
public int logoutUser(ComponentName who) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int callingUserId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
@@ -10077,7 +10078,7 @@
@Override
public List<UserHandle> getSecondaryUsers(ComponentName who) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceDeviceOwner(who);
return mInjector.binderWithCleanCallingIdentity(() -> {
@@ -10096,7 +10097,7 @@
@Override
public boolean isEphemeralUser(ComponentName who) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceProfileOrDeviceOwner(who);
final int callingUserId = mInjector.userHandleGetCallingUserId();
@@ -10178,7 +10179,7 @@
@Override
public void setUserRestriction(ComponentName who, String key, boolean enabledFromThisOwner,
boolean parent) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
if (!UserRestrictionsUtils.isValidRestriction(key)) {
return;
}
@@ -10324,7 +10325,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
final ActiveAdmin activeAdmin = getActiveAdminForCallerLocked(who,
@@ -10559,7 +10560,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin ap = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -10653,7 +10654,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -10674,7 +10675,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -10696,7 +10697,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -10717,7 +10718,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -10797,7 +10798,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -10818,7 +10819,7 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -10840,8 +10841,8 @@
@Override
public void setLockTaskPackages(ComponentName who, String[] packages)
throws SecurityException {
- Preconditions.checkNotNull(who, "ComponentName is null");
- Preconditions.checkNotNull(packages, "packages is null");
+ Objects.requireNonNull(who, "ComponentName is null");
+ Objects.requireNonNull(packages, "packages is null");
synchronized (getLockObject()) {
enforceCanCallLockTaskLocked(who);
@@ -10861,7 +10862,7 @@
@Override
public String[] getLockTaskPackages(ComponentName who) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = mInjector.binderGetCallingUserHandle().getIdentifier();
synchronized (getLockObject()) {
@@ -10881,7 +10882,7 @@
@Override
public void setLockTaskFeatures(ComponentName who, int flags) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
// Throw if Overview is used without Home.
boolean hasHome = (flags & LOCK_TASK_FEATURE_HOME) != 0;
@@ -10908,7 +10909,7 @@
@Override
public int getLockTaskFeatures(ComponentName who) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
enforceCanCallLockTaskLocked(who);
@@ -10978,7 +10979,7 @@
@Override
public void setGlobalSetting(ComponentName who, String setting, String value) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.SET_GLOBAL_SETTING)
@@ -11018,7 +11019,7 @@
@Override
public void setSystemSetting(ComponentName who, String setting, String value) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
Preconditions.checkStringNotEmpty(setting, "String setting is null or empty");
synchronized (getLockObject()) {
@@ -11038,7 +11039,7 @@
@Override
public void setLocationEnabled(ComponentName who, boolean locationEnabled) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceDeviceOwner(who);
UserHandle userHandle = mInjector.binderGetCallingUserHandle();
@@ -11057,7 +11058,7 @@
@Override
public boolean setTime(ComponentName who, long millis) {
- Preconditions.checkNotNull(who, "ComponentName is null in setTime");
+ Objects.requireNonNull(who, "ComponentName is null in setTime");
enforceDeviceOwner(who);
// Don't allow set time when auto time is on.
if (mInjector.settingsGlobalGetInt(Global.AUTO_TIME, 0) == 1) {
@@ -11072,7 +11073,7 @@
@Override
public boolean setTimeZone(ComponentName who, String timeZone) {
- Preconditions.checkNotNull(who, "ComponentName is null in setTimeZone");
+ Objects.requireNonNull(who, "ComponentName is null in setTimeZone");
enforceDeviceOwner(who);
// Don't allow set timezone when auto timezone is on.
if (mInjector.settingsGlobalGetInt(Global.AUTO_TIME_ZONE, 0) == 1) {
@@ -11088,7 +11089,7 @@
@Override
public void setSecureSetting(ComponentName who, String setting, String value) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
int callingUserId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
@@ -11159,7 +11160,7 @@
@Override
public void setMasterVolumeMuted(ComponentName who, boolean on) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
setUserRestriction(who, UserManager.DISALLOW_UNMUTE_DEVICE, on, /* parent */ false);
@@ -11173,7 +11174,7 @@
@Override
public boolean isMasterVolumeMuted(ComponentName who) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -11186,7 +11187,7 @@
@Override
public void setUserIcon(ComponentName who, Bitmap icon) {
synchronized (getLockObject()) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
int userId = UserHandle.getCallingUserId();
@@ -11201,7 +11202,7 @@
@Override
public boolean setKeyguardDisabled(ComponentName who, boolean disabled) {
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -11664,7 +11665,7 @@
@Override
public Intent createAdminSupportIntent(String restriction) {
- Preconditions.checkNotNull(restriction);
+ Objects.requireNonNull(restriction);
final int uid = mInjector.binderGetCallingUid();
final int userId = UserHandle.getUserId(uid);
Intent intent = null;
@@ -11922,7 +11923,7 @@
@Override
public SystemUpdateInfo getPendingSystemUpdate(ComponentName admin) {
- Preconditions.checkNotNull(admin, "ComponentName is null");
+ Objects.requireNonNull(admin, "ComponentName is null");
enforceProfileOrDeviceOwner(admin);
return mOwners.getSystemUpdateInfo();
@@ -11964,7 +11965,7 @@
public void setPermissionGrantState(ComponentName admin, String callerPackage,
String packageName, String permission, int grantState, RemoteCallback callback)
throws RemoteException {
- Preconditions.checkNotNull(callback);
+ Objects.requireNonNull(callback);
UserHandle user = mInjector.binderGetCallingUserHandle();
synchronized (getLockObject()) {
@@ -12099,7 +12100,7 @@
@Override
public boolean isProvisioningAllowed(String action, String packageName) {
- Preconditions.checkNotNull(packageName);
+ Objects.requireNonNull(packageName);
final int callingUid = mInjector.binderGetCallingUid();
final long ident = mInjector.binderClearCallingIdentity();
@@ -12119,7 +12120,7 @@
@Override
public int checkProvisioningPreCondition(String action, String packageName) {
- Preconditions.checkNotNull(packageName);
+ Objects.requireNonNull(packageName);
enforceCanManageProfileAndDeviceOwners();
return checkProvisioningPreConditionSkipPermission(action, packageName);
}
@@ -12359,7 +12360,7 @@
@Override
public void reboot(ComponentName admin) {
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
// Make sure caller has DO.
enforceDeviceOwner(admin);
mInjector.binderWithCleanCallingIdentity(() -> {
@@ -12380,7 +12381,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForUidLocked(who, mInjector.binderGetCallingUid());
@@ -12400,7 +12401,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForUidLocked(who, mInjector.binderGetCallingUid());
return admin.shortSupportMessage;
@@ -12412,7 +12413,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForUidLocked(who, mInjector.binderGetCallingUid());
@@ -12432,7 +12433,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForUidLocked(who, mInjector.binderGetCallingUid());
return admin.longSupportMessage;
@@ -12444,7 +12445,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceSystemCaller("query support message for user");
synchronized (getLockObject()) {
@@ -12461,7 +12462,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceSystemCaller("query support message for user");
synchronized (getLockObject()) {
@@ -12478,7 +12479,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = mInjector.userHandleGetCallingUserId();
enforceManagedProfile(userHandle, "set organization color");
synchronized (getLockObject()) {
@@ -12513,7 +12514,7 @@
if (!mHasFeature) {
return ActiveAdmin.DEF_ORGANIZATION_COLOR;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceManagedProfile(mInjector.userHandleGetCallingUserId(), "get organization color");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
@@ -12542,7 +12543,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
final int userHandle = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
@@ -12561,7 +12562,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceManagedProfile(mInjector.userHandleGetCallingUserId(), "get organization name");
synchronized (getLockObject()) {
ActiveAdmin admin = getActiveAdminForCallerLocked(who,
@@ -12599,8 +12600,8 @@
@Override
public List<String> setMeteredDataDisabledPackages(ComponentName who, List<String> packageNames) {
- Preconditions.checkNotNull(who);
- Preconditions.checkNotNull(packageNames);
+ Objects.requireNonNull(who);
+ Objects.requireNonNull(packageNames);
if (!mHasFeature) {
return packageNames;
@@ -12646,7 +12647,7 @@
@Override
public List<String> getMeteredDataDisabledPackages(ComponentName who) {
- Preconditions.checkNotNull(who);
+ Objects.requireNonNull(who);
if (!mHasFeature) {
return new ArrayList<>();
@@ -12662,7 +12663,7 @@
@Override
public boolean isMeteredDataDisabledPackageForUser(ComponentName who,
String packageName, int userId) {
- Preconditions.checkNotNull(who);
+ Objects.requireNonNull(who);
if (!mHasFeature) {
return false;
@@ -12688,7 +12689,7 @@
public void markProfileOwnerOnOrganizationOwnedDevice(ComponentName who, int userId) {
// As the caller is the system, it must specify the component name of the profile owner
// as a sanity / safety check.
- Preconditions.checkNotNull(who);
+ Objects.requireNonNull(who);
if (!mHasFeature) {
return;
@@ -12808,7 +12809,7 @@
return Collections.emptyList();
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
return new ArrayList<String>(
@@ -12877,7 +12878,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
@@ -12907,7 +12908,7 @@
synchronized (getLockObject()) {
if (!isCallerWithSystemUid()) {
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
}
return mInjector.securityLogGetLoggingEnabledProperty();
@@ -12931,7 +12932,7 @@
return null;
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
ensureDeviceOwnerAndAllUsersAffiliated(admin);
DevicePolicyEventLogger
@@ -12961,7 +12962,7 @@
return null;
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
ensureDeviceOwnerAndAllUsersAffiliated(admin);
if (!mInjector.securityLogGetLoggingEnabledProperty()) {
@@ -13206,7 +13207,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
enforceProfileOrDeviceOwner(admin);
int userId = mInjector.userHandleGetCallingUserId();
toggleBackupServiceActive(userId, enabled);
@@ -13214,7 +13215,7 @@
@Override
public boolean isBackupServiceEnabled(ComponentName admin) {
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
if (!mHasFeature) {
return true;
}
@@ -13239,14 +13240,14 @@
if (!mHasFeature) {
return false;
}
- Preconditions.checkNotNull(admin);
- Preconditions.checkNotNull(caller);
- Preconditions.checkNotNull(serviceIntent);
+ Objects.requireNonNull(admin);
+ Objects.requireNonNull(caller);
+ Objects.requireNonNull(serviceIntent);
Preconditions.checkArgument(
serviceIntent.getComponent() != null || serviceIntent.getPackage() != null,
"Service intent must be explicit (with a package name or component): "
+ serviceIntent);
- Preconditions.checkNotNull(connection);
+ Objects.requireNonNull(connection);
Preconditions.checkArgument(mInjector.userHandleGetCallingUserId() != targetUserId,
"target user id must be different from the calling user id");
@@ -13290,7 +13291,7 @@
if (!mHasFeature) {
return Collections.emptyList();
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -13755,7 +13756,7 @@
if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) {
return false;
}
- Preconditions.checkNotNull(token);
+ Objects.requireNonNull(token);
synchronized (getLockObject()) {
final int userHandle = mInjector.userHandleGetCallingUserId();
getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -13791,9 +13792,9 @@
@Override
public void clearApplicationUserData(ComponentName admin, String packageName,
IPackageDataObserver callback) {
- Preconditions.checkNotNull(admin, "ComponentName is null");
- Preconditions.checkNotNull(packageName, "packageName is null");
- Preconditions.checkNotNull(callback, "callback is null");
+ Objects.requireNonNull(admin, "ComponentName is null");
+ Objects.requireNonNull(packageName, "packageName is null");
+ Objects.requireNonNull(callback, "callback is null");
enforceProfileOrDeviceOwner(admin);
final int userId = UserHandle.getCallingUserId();
@@ -13824,7 +13825,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
synchronized (getLockObject()) {
ActiveAdmin deviceOwner =
@@ -13865,8 +13866,8 @@
return;
}
- Preconditions.checkNotNull(admin, "Admin cannot be null.");
- Preconditions.checkNotNull(target, "Target cannot be null.");
+ Objects.requireNonNull(admin, "Admin cannot be null.");
+ Objects.requireNonNull(target, "Target cannot be null.");
enforceProfileOrDeviceOwner(admin);
@@ -14001,7 +14002,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
final String startUserSessionMessageString =
startUserSessionMessage != null ? startUserSessionMessage.toString() : null;
@@ -14026,7 +14027,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
final String endUserSessionMessageString =
endUserSessionMessage != null ? endUserSessionMessage.toString() : null;
@@ -14051,7 +14052,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
synchronized (getLockObject()) {
final ActiveAdmin deviceOwner =
@@ -14065,7 +14066,7 @@
if (!mHasFeature) {
return null;
}
- Preconditions.checkNotNull(admin);
+ Objects.requireNonNull(admin);
synchronized (getLockObject()) {
final ActiveAdmin deviceOwner =
@@ -14108,8 +14109,8 @@
if (!mHasFeature || !mHasTelephonyFeature) {
return -1;
}
- Preconditions.checkNotNull(who, "ComponentName is null in addOverrideApn");
- Preconditions.checkNotNull(apnSetting, "ApnSetting is null in addOverrideApn");
+ Objects.requireNonNull(who, "ComponentName is null in addOverrideApn");
+ Objects.requireNonNull(apnSetting, "ApnSetting is null in addOverrideApn");
enforceDeviceOwner(who);
int operatedId = -1;
@@ -14132,8 +14133,8 @@
if (!mHasFeature || !mHasTelephonyFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null in updateOverrideApn");
- Preconditions.checkNotNull(apnSetting, "ApnSetting is null in updateOverrideApn");
+ Objects.requireNonNull(who, "ComponentName is null in updateOverrideApn");
+ Objects.requireNonNull(apnSetting, "ApnSetting is null in updateOverrideApn");
enforceDeviceOwner(who);
if (apnId < 0) {
@@ -14150,7 +14151,7 @@
if (!mHasFeature || !mHasTelephonyFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null in removeOverrideApn");
+ Objects.requireNonNull(who, "ComponentName is null in removeOverrideApn");
enforceDeviceOwner(who);
return removeOverrideApnUnchecked(apnId);
@@ -14171,7 +14172,7 @@
if (!mHasFeature || !mHasTelephonyFeature) {
return Collections.emptyList();
}
- Preconditions.checkNotNull(who, "ComponentName is null in getOverrideApns");
+ Objects.requireNonNull(who, "ComponentName is null in getOverrideApns");
enforceDeviceOwner(who);
return getOverrideApnsUnchecked();
@@ -14202,7 +14203,7 @@
if (!mHasFeature || !mHasTelephonyFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null in setOverrideApnEnabled");
+ Objects.requireNonNull(who, "ComponentName is null in setOverrideApnEnabled");
enforceDeviceOwner(who);
setOverrideApnsEnabledUnchecked(enabled);
@@ -14220,7 +14221,7 @@
if (!mHasFeature || !mHasTelephonyFeature) {
return false;
}
- Preconditions.checkNotNull(who, "ComponentName is null in isOverrideApnEnabled");
+ Objects.requireNonNull(who, "ComponentName is null in isOverrideApnEnabled");
enforceDeviceOwner(who);
Cursor enforceCursor = mInjector.binderWithCleanCallingIdentity(
@@ -14304,7 +14305,7 @@
return PRIVATE_DNS_SET_ERROR_FAILURE_SETTING;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceDeviceOwner(who);
final int returnCode;
@@ -14342,7 +14343,7 @@
return PRIVATE_DNS_MODE_UNKNOWN;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceDeviceOwner(who);
String currentMode = mInjector.settingsGlobalGetString(PRIVATE_DNS_MODE);
if (currentMode == null) {
@@ -14366,7 +14367,7 @@
return null;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
enforceDeviceOwner(who);
return mInjector.settingsGlobalGetString(PRIVATE_DNS_SPECIFIER);
@@ -14404,7 +14405,7 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
final ActiveAdmin admin = getActiveAdminForCallerLocked(
@@ -14425,7 +14426,7 @@
if (!mHasFeature) {
return Collections.emptyList();
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
final ActiveAdmin admin = getActiveAdminForCallerLocked(
@@ -14479,8 +14480,8 @@
if (!mHasFeature) {
return;
}
- Preconditions.checkNotNull(who, "ComponentName is null");
- Preconditions.checkNotNull(packageNames, "Package names is null");
+ Objects.requireNonNull(who, "ComponentName is null");
+ Objects.requireNonNull(packageNames, "Package names is null");
synchronized (getLockObject()) {
final ActiveAdmin admin =
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -14494,7 +14495,7 @@
if (!mHasFeature) {
return Collections.emptyList();
}
- Preconditions.checkNotNull(who, "ComponentName is null");
+ Objects.requireNonNull(who, "ComponentName is null");
synchronized (getLockObject()) {
final ActiveAdmin admin = getActiveAdminForCallerLocked(
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/TransferOwnershipMetadataManager.java b/services/devicepolicy/java/com/android/server/devicepolicy/TransferOwnershipMetadataManager.java
index dd3bfc3..4b66bea 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/TransferOwnershipMetadataManager.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/TransferOwnershipMetadataManager.java
@@ -39,6 +39,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.util.Objects;
/**
* Handles reading and writing of the owner transfer metadata file.
@@ -185,8 +186,8 @@
@NonNull int userId, @NonNull String adminType) {
this.sourceComponent = sourceComponent;
this.targetComponent = targetComponent;
- Preconditions.checkNotNull(sourceComponent);
- Preconditions.checkNotNull(targetComponent);
+ Objects.requireNonNull(sourceComponent);
+ Objects.requireNonNull(targetComponent);
Preconditions.checkStringNotEmpty(adminType);
this.userId = userId;
this.adminType = adminType;
@@ -199,7 +200,7 @@
}
private static ComponentName unflattenComponentUnchecked(String flatComponent) {
- Preconditions.checkNotNull(flatComponent);
+ Objects.requireNonNull(flatComponent);
return ComponentName.unflattenFromString(flatComponent);
}
diff --git a/services/tests/servicestests/AndroidTest.xml b/services/tests/servicestests/AndroidTest.xml
index d34f783..bbc6bdb 100644
--- a/services/tests/servicestests/AndroidTest.xml
+++ b/services/tests/servicestests/AndroidTest.xml
@@ -26,6 +26,11 @@
<option name="test-file-name" value="SimpleServiceTestApp.apk" />
</target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="cleanup" value="true" />
+ <option name="push" value="AppIntegrityManagerServiceTestApp.apk->/data/local/tmp/AppIntegrityManagerServiceTestApp.apk" />
+ </target_preparer>
+
<option name="test-tag" value="FrameworksServicesTests" />
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.frameworks.servicestests" />
diff --git a/services/tests/servicestests/assets/AppIntegrityManagerServiceImplTest/test.apk b/services/tests/servicestests/assets/AppIntegrityManagerServiceImplTest/test.apk
deleted file mode 100644
index 6345c98..0000000
--- a/services/tests/servicestests/assets/AppIntegrityManagerServiceImplTest/test.apk
+++ /dev/null
Binary files differ
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/MockUtils.java b/services/tests/servicestests/src/com/android/server/devicepolicy/MockUtils.java
index 17e5832..09a6819 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/MockUtils.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/MockUtils.java
@@ -17,7 +17,6 @@
import com.google.common.base.Objects;
-import com.android.internal.util.Preconditions;
import com.android.server.pm.UserRestrictionsUtils;
import android.content.ComponentName;
@@ -107,7 +106,7 @@
}
public static Bundle checkUserRestrictions(String... keys) {
- final Bundle expected = DpmTestUtils.newRestrictions(Preconditions.checkNotNull(keys));
+ final Bundle expected = DpmTestUtils.newRestrictions(java.util.Objects.requireNonNull(keys));
final Matcher<Bundle> m = new BaseMatcher<Bundle>() {
@Override
public boolean matches(Object item) {
diff --git a/services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java b/services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java
index a2376a6..604efc4 100644
--- a/services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java
+++ b/services/tests/servicestests/src/com/android/server/integrity/AppIntegrityManagerServiceImplTest.java
@@ -32,6 +32,7 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -64,7 +65,6 @@
import com.android.server.integrity.model.IntegrityCheckResult;
import com.android.server.testutils.TestUtils;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -75,9 +75,6 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -86,7 +83,8 @@
/** Unit test for {@link com.android.server.integrity.AppIntegrityManagerServiceImpl} */
@RunWith(AndroidJUnit4.class)
public class AppIntegrityManagerServiceImplTest {
- private static final String TEST_DIR = "AppIntegrityManagerServiceImplTest";
+ private static final String TEST_APP_PATH =
+ "/data/local/tmp/AppIntegrityManagerServiceTestApp.apk";
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
private static final String VERSION = "version";
@@ -97,13 +95,19 @@
private static final String INSTALLER = TEST_FRAMEWORK_PACKAGE;
// These are obtained by running the test and checking logcat.
private static final String APP_CERT =
- "949ADC6CB92FF09E3784D6E9504F26F9BEAC06E60D881D55A6A81160F9CD6FD1";
+ "301AA3CB081134501C45F1422ABC66C24224FD5DED5FDC8F17E697176FD866AA";
private static final String INSTALLER_CERT =
"301AA3CB081134501C45F1422ABC66C24224FD5DED5FDC8F17E697176FD866AA";
// We use SHA256 for package names longer than 32 characters.
private static final String INSTALLER_SHA256 =
"786933C28839603EB48C50B2A688DC6BE52C833627CB2731FF8466A2AE9F94CD";
+ private static final String PLAY_STORE_PKG = "com.android.vending";
+ private static final String ADB_INSTALLER = "adb";
+ private static final String PLAY_STORE_CERT =
+ "play_store_cert";
+ private static final String ADB_CERT = "";
+
@org.junit.Rule public MockitoRule mMockitoRule = MockitoJUnit.rule();
@Mock PackageManagerInternal mPackageManagerInternal;
@@ -122,11 +126,7 @@
@Before
public void setup() throws Exception {
- mTestApk = File.createTempFile("TestApk", /* suffix= */ null);
- mTestApk.deleteOnExit();
- try (InputStream inputStream = mRealContext.getAssets().open(TEST_DIR + "/test.apk")) {
- Files.copy(inputStream, mTestApk.toPath(), StandardCopyOption.REPLACE_EXISTING);
- }
+ mTestApk = new File(TEST_APP_PATH);
mService =
new AppIntegrityManagerServiceImpl(
@@ -141,11 +141,7 @@
when(mMockContext.getPackageManager()).thenReturn(mSpyPackageManager);
when(mMockContext.getResources()).thenReturn(mMockResources);
when(mMockResources.getStringArray(anyInt())).thenReturn(new String[] {});
- }
-
- @After
- public void tearDown() throws Exception {
- mTestApk.delete();
+ when(mIntegrityFileManager.initialized()).thenReturn(true);
}
// This is not a test of the class, but more of a safeguard that we don't block any install in
@@ -310,10 +306,10 @@
assertEquals(INSTALLER_CERT, appInstallMetadata.getInstallerCertificate());
assertEquals(VERSION_CODE, appInstallMetadata.getVersionCode());
assertFalse(appInstallMetadata.isPreInstalled());
- // These are hardcoded in the test apk
+ // These are hardcoded in the test apk android manifest
assertEquals(2, allowedInstallers.size());
- assertEquals("cert_1", allowedInstallers.get("store_1"));
- assertEquals("cert_2", allowedInstallers.get("store_2"));
+ assertEquals(PLAY_STORE_CERT, allowedInstallers.get(PLAY_STORE_PKG));
+ assertEquals(ADB_CERT, allowedInstallers.get(ADB_INSTALLER));
}
@Test
@@ -356,6 +352,25 @@
1, PackageManagerInternal.INTEGRITY_VERIFICATION_REJECT);
}
+ @Test
+ public void handleBroadcast_notInitialized() throws Exception {
+ when(mIntegrityFileManager.initialized()).thenReturn(false);
+ ArgumentCaptor<BroadcastReceiver> broadcastReceiverCaptor =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ verify(mMockContext)
+ .registerReceiver(broadcastReceiverCaptor.capture(), any(), any(), any());
+ Intent intent = makeVerificationIntent();
+ when(mRuleEvaluationEngine.evaluate(any(), any())).thenReturn(IntegrityCheckResult.allow());
+
+ broadcastReceiverCaptor.getValue().onReceive(mMockContext, intent);
+ runJobInHandler();
+
+ verify(mPackageManagerInternal)
+ .setIntegrityVerificationResult(
+ 1, PackageManagerInternal.INTEGRITY_VERIFICATION_ALLOW);
+ verify(mSpyPackageManager, never()).getPackageArchiveInfo(any(), anyInt());
+ }
+
private void whitelistUsAsRuleProvider() {
Resources mockResources = mock(Resources.class);
when(mockResources.getStringArray(R.array.config_integrityRuleProviderPackages))
diff --git a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
index f9fc3a1..41416f1 100644
--- a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
@@ -88,7 +88,6 @@
import android.util.Log;
import android.util.Pair;
-import com.android.internal.util.Preconditions;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.pm.LauncherAppsService.LauncherAppsImpl;
@@ -114,6 +113,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
@@ -1241,7 +1241,7 @@
protected void setCaller(String packageName, int userId) {
mInjectedClientPackage = packageName;
mInjectedCallingUid =
- Preconditions.checkNotNull(getInjectedPackageInfo(packageName, userId, false),
+ Objects.requireNonNull(getInjectedPackageInfo(packageName, userId, false),
"Unknown package").applicationInfo.uid;
// Set up LauncherApps for this caller.
diff --git a/services/tests/servicestests/test-apps/AppIntegrityManagerServiceTestApp/Android.bp b/services/tests/servicestests/test-apps/AppIntegrityManagerServiceTestApp/Android.bp
new file mode 100644
index 0000000..9aaa37d
--- /dev/null
+++ b/services/tests/servicestests/test-apps/AppIntegrityManagerServiceTestApp/Android.bp
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test_helper_app {
+ name: "AppIntegrityManagerServiceTestApp",
+
+ test_suites: ["device-tests"],
+
+ certificate: "platform",
+}
diff --git a/services/tests/servicestests/test-apps/AppIntegrityManagerServiceTestApp/AndroidManifest.xml b/services/tests/servicestests/test-apps/AppIntegrityManagerServiceTestApp/AndroidManifest.xml
new file mode 100644
index 0000000..f5dbf43
--- /dev/null
+++ b/services/tests/servicestests/test-apps/AppIntegrityManagerServiceTestApp/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.google.android.appintegritymanager.test.app"
+ android:versionCode="5000">
+
+ <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="28" />
+
+ <application android:hasCode="false">
+ <meta-data android:name="allowed-installers" android:value="com.android.vending|play_store_cert,adb|"/>
+ </application>
+</manifest>
+
diff --git a/wifi/java/android/net/wifi/WifiClient.java b/wifi/java/android/net/wifi/WifiClient.java
index 3e09580..3794566 100644
--- a/wifi/java/android/net/wifi/WifiClient.java
+++ b/wifi/java/android/net/wifi/WifiClient.java
@@ -22,8 +22,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import com.android.internal.util.Preconditions;
-
import java.util.Objects;
/** @hide */
@@ -46,7 +44,7 @@
/** @hide */
public WifiClient(@NonNull MacAddress macAddress) {
- Preconditions.checkNotNull(macAddress, "mMacAddress must not be null.");
+ Objects.requireNonNull(macAddress, "mMacAddress must not be null.");
this.mMacAddress = macAddress;
}
diff --git a/wifi/java/android/net/wifi/WifiNetworkScoreCache.java b/wifi/java/android/net/wifi/WifiNetworkScoreCache.java
index be37c22..378549d 100755
--- a/wifi/java/android/net/wifi/WifiNetworkScoreCache.java
+++ b/wifi/java/android/net/wifi/WifiNetworkScoreCache.java
@@ -29,11 +29,11 @@
import android.util.LruCache;
import com.android.internal.annotations.GuardedBy;
-import com.android.internal.util.Preconditions;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.List;
+import java.util.Objects;
/**
* {@link INetworkScoreCache} implementation for Wifi Networks.
@@ -290,7 +290,7 @@
* This cannot be null.
*/
public CacheListener(@NonNull Handler handler) {
- Preconditions.checkNotNull(handler);
+ Objects.requireNonNull(handler);
mHandler = handler;
}
diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java
index 8badcc0..2c39c32a 100644
--- a/wifi/java/android/net/wifi/WifiScanner.java
+++ b/wifi/java/android/net/wifi/WifiScanner.java
@@ -40,7 +40,6 @@
import android.util.SparseArray;
import com.android.internal.util.AsyncChannel;
-import com.android.internal.util.Preconditions;
import com.android.internal.util.Protocol;
import java.lang.annotation.Retention;
@@ -48,6 +47,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.Executor;
/**
@@ -840,8 +840,8 @@
@RequiresPermission(Manifest.permission.NETWORK_STACK)
public void registerScanListener(@NonNull @CallbackExecutor Executor executor,
@NonNull ScanListener listener) {
- Preconditions.checkNotNull(executor, "executor cannot be null");
- Preconditions.checkNotNull(listener, "listener cannot be null");
+ Objects.requireNonNull(executor, "executor cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
int key = addListener(listener, executor);
if (key == INVALID_KEY) return;
validateChannel();
@@ -864,7 +864,7 @@
* #registerScanListener}
*/
public void unregisterScanListener(@NonNull ScanListener listener) {
- Preconditions.checkNotNull(listener, "listener cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
int key = removeListener(listener);
if (key == INVALID_KEY) return;
validateChannel();
@@ -894,7 +894,7 @@
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void startBackgroundScan(ScanSettings settings, ScanListener listener,
WorkSource workSource) {
- Preconditions.checkNotNull(listener, "listener cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
int key = addListener(listener);
if (key == INVALID_KEY) return;
validateChannel();
@@ -913,7 +913,7 @@
*/
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void stopBackgroundScan(ScanListener listener) {
- Preconditions.checkNotNull(listener, "listener cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
int key = removeListener(listener);
if (key == INVALID_KEY) return;
validateChannel();
@@ -962,7 +962,7 @@
*/
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void startScan(ScanSettings settings, ScanListener listener, WorkSource workSource) {
- Preconditions.checkNotNull(listener, "listener cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
int key = addListener(listener);
if (key == INVALID_KEY) return;
validateChannel();
@@ -981,7 +981,7 @@
*/
@RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void stopScan(ScanListener listener) {
- Preconditions.checkNotNull(listener, "listener cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
int key = removeListener(listener);
if (key == INVALID_KEY) return;
validateChannel();
@@ -1036,8 +1036,8 @@
*/
public void startConnectedPnoScan(ScanSettings scanSettings, PnoSettings pnoSettings,
PnoScanListener listener) {
- Preconditions.checkNotNull(listener, "listener cannot be null");
- Preconditions.checkNotNull(pnoSettings, "pnoSettings cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
+ Objects.requireNonNull(pnoSettings, "pnoSettings cannot be null");
int key = addListener(listener);
if (key == INVALID_KEY) return;
validateChannel();
@@ -1058,8 +1058,8 @@
@RequiresPermission(android.Manifest.permission.NETWORK_STACK)
public void startDisconnectedPnoScan(ScanSettings scanSettings, PnoSettings pnoSettings,
PnoScanListener listener) {
- Preconditions.checkNotNull(listener, "listener cannot be null");
- Preconditions.checkNotNull(pnoSettings, "pnoSettings cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
+ Objects.requireNonNull(pnoSettings, "pnoSettings cannot be null");
int key = addListener(listener);
if (key == INVALID_KEY) return;
validateChannel();
@@ -1074,7 +1074,7 @@
*/
@RequiresPermission(android.Manifest.permission.NETWORK_STACK)
public void stopPnoScan(ScanListener listener) {
- Preconditions.checkNotNull(listener, "listener cannot be null");
+ Objects.requireNonNull(listener, "listener cannot be null");
int key = removeListener(listener);
if (key == INVALID_KEY) return;
validateChannel();