Debian Codegraph @

core/java/android/hardware/camera2/utils/ConcurrentCameraIdCombination.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 * ConcurrentCameraIdCombination
27 *
28 * Includes a list of camera ids that may have sessions configured concurrently.
29 * @hide
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 * helper for CREATOR
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 * Get this concurrent camera id combination.
87 */
88 public Set<String> getConcurrentCameraIdCombination() {
89 return mConcurrentCameraIds;
90 }
91 }