2 * Copyright (c) 2020 Project CHIP Authors
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 package com.google.chip.chiptool.commissioner.thread.internal;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 import androidx.annotation.NonNull;
24 import com.google.chip.chiptool.commissioner.thread.BorderAgentInfo;
25 import com.google.chip.chiptool.commissioner.thread.ThreadNetworkInfo;
26 import java.util.ArrayList;
28 class ThreadNetworkInfoHolder implements Parcelable {
29 @NonNull private final ThreadNetworkInfo networkInfo;
31 @NonNull private final ArrayList<BorderAgentInfo> borderAgents;
33 public ThreadNetworkInfoHolder(BorderAgentInfo borderAgent) {
34 networkInfo = new ThreadNetworkInfo(borderAgent.networkName, borderAgent.extendedPanId);
35 borderAgents = new ArrayList<>();
36 borderAgents.add(borderAgent);
39 protected ThreadNetworkInfoHolder(Parcel in) {
40 networkInfo = in.readParcelable(ThreadNetworkInfo.class.getClassLoader());
41 borderAgents = in.createTypedArrayList(BorderAgentInfo.CREATOR);
44 public static final Creator<ThreadNetworkInfoHolder> CREATOR =
45 new Creator<ThreadNetworkInfoHolder>() {
47 public ThreadNetworkInfoHolder createFromParcel(Parcel in) {
48 return new ThreadNetworkInfoHolder(in);
52 public ThreadNetworkInfoHolder[] newArray(int size) {
53 return new ThreadNetworkInfoHolder[size];
57 public ThreadNetworkInfo getNetworkInfo() {
61 public ArrayList<BorderAgentInfo> getBorderAgents() {
66 public int describeContents() {
71 public void writeToParcel(Parcel dest, int flags) {
72 dest.writeParcelable(networkInfo, flags);
73 dest.writeParcelableArray((BorderAgentInfo[]) borderAgents.toArray(), flags);