| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.hardware.camera2.utils; |
| 17 |
|
| 18 |
import android.annotation.NonNull; |
| 19 |
import android.os.Parcel; |
| 20 |
import android.os.Parcelable; |
| 21 |
|
| 22 |
import java.util.HashSet; |
| 23 |
import java.util.Set; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class ConcurrentCameraIdCombination implements Parcelable { |
| 32 |
|
| 33 |
private Set<String> mConcurrentCameraIds = new HashSet<>(); |
| 34 |
|
| 35 |
public static final @NonNull |
| 36 |
Parcelable.Creator<ConcurrentCameraIdCombination> CREATOR = |
| 37 |
new Parcelable.Creator<ConcurrentCameraIdCombination>() { |
| 38 |
@Override |
| 39 |
public ConcurrentCameraIdCombination createFromParcel(Parcel in) { |
| 40 |
return new ConcurrentCameraIdCombination(in); |
| 41 |
} |
| 42 |
|
| 43 |
@Override |
| 44 |
public ConcurrentCameraIdCombination[] newArray(int size) { |
| 45 |
return new ConcurrentCameraIdCombination[size]; |
| 46 |
} |
| 47 |
}; |
| 48 |
|
| 49 |
private ConcurrentCameraIdCombination(Parcel in) { |
| 50 |
readFromParcel(in); |
| 51 |
} |
| 52 |
|
| 53 |
@Override |
| 54 |
public int describeContents() { |
| 55 |
return 0; |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
public void writeToParcel(Parcel dest, int flags) { |
| 60 |
dest.writeInt(mConcurrentCameraIds.size()); |
| 61 |
for (String cameraId : mConcurrentCameraIds) { |
| 62 |
dest.writeString(cameraId); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public void readFromParcel(Parcel in) { |
| 70 |
mConcurrentCameraIds.clear(); |
| 71 |
int cameraCombinationSize = in.readInt(); |
| 72 |
if (cameraCombinationSize < 0) { |
| 73 |
throw new RuntimeException("cameraCombinationSize " + cameraCombinationSize |
| 74 |
+ " should not be negative"); |
| 75 |
} |
| 76 |
for (int i = 0; i < cameraCombinationSize; i++) { |
| 77 |
String cameraId = in.readString(); |
| 78 |
if (cameraId == null) { |
| 79 |
throw new RuntimeException("Failed to read camera id from Parcel"); |
| 80 |
} |
| 81 |
mConcurrentCameraIds.add(cameraId); |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
public Set<String> getConcurrentCameraIdCombination() { |
| 89 |
return mConcurrentCameraIds; |
| 90 |
} |
| 91 |
} |