Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e2c22f5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Replace com.android.internal.util.Preconditions.checkNotNull with...

Merge "Replace com.android.internal.util.Preconditions.checkNotNull with java.util.Objects.requireNonNull"
parents 671403a8 74eafaa6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.server.backup.encryption;

import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.internal.util.Preconditions.checkState;

import android.content.Context;
@@ -29,6 +28,7 @@ import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;

import java.security.KeyStoreException;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

@@ -88,8 +88,8 @@ public class CryptoSettings {
    }

    private CryptoSettings(SharedPreferences sharedPreferences, Context context) {
        mSharedPreferences = checkNotNull(sharedPreferences);
        mContext = checkNotNull(context);
        mSharedPreferences = Objects.requireNonNull(sharedPreferences);
        mContext = Objects.requireNonNull(context);
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.backup.encryption.chunking;

import static com.android.internal.util.Preconditions.checkArgument;
import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.internal.util.Preconditions.checkState;

import android.annotation.Nullable;
@@ -35,6 +34,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * Writes batches of {@link EncryptedChunk} to a diff script, and generates the associated {@link
@@ -174,7 +174,7 @@ public class BackupFileBuilder {
     * IllegalStateException}.
     */
    public void finish(ChunksMetadataProto.ChunksMetadata metadata) throws IOException {
        checkNotNull(metadata, "Metadata cannot be null");
        Objects.requireNonNull(metadata, "Metadata cannot be null");

        long startOfMetadata = mBackupWriter.getBytesWritten();
        mBackupWriter.writeBytes(ChunksMetadataProto.ChunksMetadata.toByteArray(metadata));
@@ -190,7 +190,7 @@ public class BackupFileBuilder {
     */
    private void writeChunkToFileAndListing(
            ChunkHash chunkHash, Map<ChunkHash, EncryptedChunk> newChunks) throws IOException {
        checkNotNull(chunkHash, "Hash cannot be null");
        Objects.requireNonNull(chunkHash, "Hash cannot be null");

        if (mOldChunkListing.hasChunk(chunkHash)) {
            ChunkListingMap.Entry oldChunk = mOldChunkListing.getChunkEntry(chunkHash);
+3 −4
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.server.backup.encryption.chunking;

import static com.android.internal.util.Preconditions.checkNotNull;

import android.content.Context;
import android.text.TextUtils;
import android.util.AtomicFile;
@@ -34,6 +32,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Objects;
import java.util.Optional;

/**
@@ -75,7 +74,7 @@ public class ProtoStore<T extends MessageNano> {
     */
    @VisibleForTesting
    ProtoStore(Class<T> clazz, File storeFolder) throws IOException {
        mClazz = checkNotNull(clazz);
        mClazz = Objects.requireNonNull(clazz);
        mStoreFolder = ensureDirectoryExistsOrThrow(storeFolder);
    }

@@ -118,7 +117,7 @@ public class ProtoStore<T extends MessageNano> {

    /** Saves a proto to disk, associating it with the given package. */
    public void saveProto(String packageName, T proto) throws IOException {
        checkNotNull(proto);
        Objects.requireNonNull(proto);
        File file = getFileForPackage(packageName);

        try (FileOutputStream os = new FileOutputStream(file)) {
+4 −5
Original line number Diff line number Diff line
@@ -16,10 +16,9 @@

package com.android.server.backup.encryption.chunking.cdc;

import static com.android.internal.util.Preconditions.checkNotNull;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Objects;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
@@ -49,9 +48,9 @@ public final class Hkdf {
     * @throws InvalidKeyException If the salt can not be used as a valid key.
     */
    static byte[] hkdf(byte[] masterKey, byte[] salt, byte[] data) throws InvalidKeyException {
        checkNotNull(masterKey, "HKDF requires master key to be set.");
        checkNotNull(salt, "HKDF requires a salt.");
        checkNotNull(data, "No data provided to HKDF.");
        Objects.requireNonNull(masterKey, "HKDF requires master key to be set.");
        Objects.requireNonNull(salt, "HKDF requires a salt.");
        Objects.requireNonNull(data, "No data provided to HKDF.");
        return hkdfSha256Expand(hkdfSha256Extract(masterKey, salt), data);
    }

+4 −4
Original line number Diff line number Diff line
@@ -16,14 +16,14 @@

package com.android.server.backup.encryption.keys;

import static com.android.internal.util.Preconditions.checkNotNull;

import android.annotation.IntDef;
import android.content.Context;
import android.security.keystore.recovery.InternalRecoveryServiceException;
import android.security.keystore.recovery.RecoveryController;
import android.util.Slog;

import java.util.Objects;

import javax.crypto.SecretKey;

/**
@@ -46,8 +46,8 @@ public class RecoverableKeyStoreSecondaryKey {
     * @param secretKey The key.
     */
    public RecoverableKeyStoreSecondaryKey(String alias, SecretKey secretKey) {
        mAlias = checkNotNull(alias);
        mSecretKey = checkNotNull(secretKey);
        mAlias = Objects.requireNonNull(alias);
        mSecretKey = Objects.requireNonNull(secretKey);
    }

    /**
Loading