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

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

Merge "Add @NonNull / @Nullable annotations to android.mtp API."

parents b25c0d97 0639fe0a
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.mtp;

import android.annotation.NonNull;

/**
 * This class encapsulates information about an MTP device.
 * This corresponds to the DeviceInfo Dataset described in
@@ -39,7 +41,7 @@ public class MtpDeviceInfo {
     *
     * @return the manufacturer name
     */
    public final String getManufacturer() {
    public final @NonNull String getManufacturer() {
        return mManufacturer;
    }

@@ -48,7 +50,7 @@ public class MtpDeviceInfo {
     *
     * @return the model name
     */
    public final String getModel() {
    public final @NonNull String getModel() {
        return mModel;
    }

@@ -57,7 +59,7 @@ public class MtpDeviceInfo {
     *
     * @return the device version
     */
    public final String getVersion() {
    public final @NonNull String getVersion() {
        return mVersion;
    }

@@ -66,7 +68,7 @@ public class MtpDeviceInfo {
     *
     * @return the serial number
     */
    public final String getSerialNumber() {
    public final @NonNull String getSerialNumber() {
        return mSerialNumber;
    }

@@ -110,7 +112,7 @@ public class MtpDeviceInfo {
     * @see MtpConstants#OPERATION_SET_OBJECT_REFERENCES
     * @see MtpConstants#OPERATION_SKIP
     */
    public final int[] getOperationsSupported() {
    public final @NonNull int[] getOperationsSupported() {
        return mOperationsSupported;
    }

@@ -137,7 +139,7 @@ public class MtpDeviceInfo {
     * @see MtpEvent#EVENT_OBJECT_PROP_DESC_CHANGED
     * @see MtpEvent#EVENT_OBJECT_REFERENCES_CHANGED
     */
    public final int[] getEventsSupported() {
    public final @NonNull int[] getEventsSupported() {
        return mEventsSupported;
    }

@@ -163,7 +165,7 @@ public class MtpDeviceInfo {
     * Returns if the code set contains code.
     * @hide
     */
    private static boolean isSupported(int[] set, int code) {
    private static boolean isSupported(@NonNull int[] set, int code) {
        for (final int element : set) {
            if (element == code) {
                return true;
+19 −6
Original line number Diff line number Diff line
@@ -16,8 +16,13 @@

package android.mtp;

import android.annotation.NonNull;
import android.os.Build;

import com.android.internal.util.Preconditions;

import dalvik.system.VMRuntime;

/**
 * This class encapsulates information about an object on an MTP device.
 * This corresponds to the ObjectInfo Dataset described in
@@ -40,10 +45,10 @@ public final class MtpObjectInfo {
    private int mAssociationType;
    private int mAssociationDesc;
    private int mSequenceNumber;
    private String mName;
    private String mName = "";
    private long mDateCreated;
    private long mDateModified;
    private String mKeywords;
    private String mKeywords = "";

    // only instantiated via JNI or via a builder
    private MtpObjectInfo() {
@@ -311,7 +316,7 @@ public final class MtpObjectInfo {
     *
     * @return the object's name
     */
    public final String getName() {
    public final @NonNull String getName() {
        return mName;
    }

@@ -340,7 +345,7 @@ public final class MtpObjectInfo {
     *
     * @return the object's keyword list
     */
    public final String getKeywords() {
    public final @NonNull String getKeywords() {
        return mKeywords;
    }

@@ -435,12 +440,20 @@ public final class MtpObjectInfo {
            return this;
        }

        public Builder setKeywords(String value) {
        public Builder setKeywords(@NonNull String value) {
            if (VMRuntime.getRuntime().getTargetSdkVersion() > Build.VERSION_CODES.N_MR1) {
                Preconditions.checkNotNull(value);
            } else if (value == null) {
                // Before N_MR1 we accept null value and it was regarded as an empty string in
                // MtpDevice#sendObjectInfo.
                value = "";
            }
            mObjectInfo.mKeywords = value;
            return this;
        }

        public Builder setName(String value) {
        public Builder setName(@NonNull String value) {
            Preconditions.checkNotNull(value);
            mObjectInfo.mName = value;
            return this;
        }
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.mtp;

import android.annotation.NonNull;

/**
 * This class encapsulates information about a storage unit on an MTP device.
 * This corresponds to the StorageInfo Dataset described in
@@ -68,7 +70,7 @@ public final class MtpStorageInfo {
     *
     * @return the storage unit description
     */
    public final String getDescription() {
    public final @NonNull String getDescription() {
        return mDescription;
    }

@@ -77,7 +79,7 @@ public final class MtpStorageInfo {
     *
     * @return the storage volume identifier
     */
    public final String getVolumeIdentifier() {
    public final @NonNull String getVolumeIdentifier() {
        return mVolumeIdentifier;
    }
}