| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.hardware.usb; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.os.Parcel; |
| 21 |
import android.os.Parcelable; |
| 22 |
|
| 23 |
import com.android.internal.annotations.Immutable; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
@Immutable |
| 31 |
public final class ParcelableUsbPort implements Parcelable { |
| 32 |
private final @NonNull String mId; |
| 33 |
private final int mSupportedModes; |
| 34 |
private final int mSupportedContaminantProtectionModes; |
| 35 |
private final boolean mSupportsEnableContaminantPresenceProtection; |
| 36 |
private final boolean mSupportsEnableContaminantPresenceDetection; |
| 37 |
|
| 38 |
private ParcelableUsbPort(@NonNull String id, int supportedModes, |
| 39 |
int supportedContaminantProtectionModes, |
| 40 |
boolean supportsEnableContaminantPresenceProtection, |
| 41 |
boolean supportsEnableContaminantPresenceDetection) { |
| 42 |
mId = id; |
| 43 |
mSupportedModes = supportedModes; |
| 44 |
mSupportedContaminantProtectionModes = supportedContaminantProtectionModes; |
| 45 |
mSupportsEnableContaminantPresenceProtection = |
| 46 |
supportsEnableContaminantPresenceProtection; |
| 47 |
mSupportsEnableContaminantPresenceDetection = |
| 48 |
supportsEnableContaminantPresenceDetection; |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public static @NonNull ParcelableUsbPort of(@NonNull UsbPort port) { |
| 59 |
return new ParcelableUsbPort(port.getId(), port.getSupportedModes(), |
| 60 |
port.getSupportedContaminantProtectionModes(), |
| 61 |
port.supportsEnableContaminantPresenceProtection(), |
| 62 |
port.supportsEnableContaminantPresenceDetection()); |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
public @NonNull UsbPort getUsbPort(@NonNull UsbManager usbManager) { |
| 73 |
return new UsbPort(usbManager, mId, mSupportedModes, mSupportedContaminantProtectionModes, |
| 74 |
mSupportsEnableContaminantPresenceProtection, |
| 75 |
mSupportsEnableContaminantPresenceDetection); |
| 76 |
} |
| 77 |
|
| 78 |
@Override |
| 79 |
public int describeContents() { |
| 80 |
return 0; |
| 81 |
} |
| 82 |
|
| 83 |
@Override |
| 84 |
public void writeToParcel(Parcel dest, int flags) { |
| 85 |
dest.writeString(mId); |
| 86 |
dest.writeInt(mSupportedModes); |
| 87 |
dest.writeInt(mSupportedContaminantProtectionModes); |
| 88 |
dest.writeBoolean(mSupportsEnableContaminantPresenceProtection); |
| 89 |
dest.writeBoolean(mSupportsEnableContaminantPresenceDetection); |
| 90 |
} |
| 91 |
|
| 92 |
public static final @android.annotation.NonNull Creator<ParcelableUsbPort> CREATOR = |
| 93 |
new Creator<ParcelableUsbPort>() { |
| 94 |
@Override |
| 95 |
public ParcelableUsbPort createFromParcel(Parcel in) { |
| 96 |
String id = in.readString(); |
| 97 |
int supportedModes = in.readInt(); |
| 98 |
int supportedContaminantProtectionModes = in.readInt(); |
| 99 |
boolean supportsEnableContaminantPresenceProtection = in.readBoolean(); |
| 100 |
boolean supportsEnableContaminantPresenceDetection = in.readBoolean(); |
| 101 |
|
| 102 |
return new ParcelableUsbPort(id, supportedModes, |
| 103 |
supportedContaminantProtectionModes, |
| 104 |
supportsEnableContaminantPresenceProtection, |
| 105 |
supportsEnableContaminantPresenceDetection); |
| 106 |
} |
| 107 |
|
| 108 |
@Override |
| 109 |
public ParcelableUsbPort[] newArray(int size) { |
| 110 |
return new ParcelableUsbPort[size]; |
| 111 |
} |
| 112 |
}; |
| 113 |
} |