diff --git a/.gitmodules b/.gitmodules
index 0467d24108891a..b5ba2319ba366a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -42,10 +42,6 @@
path = third_party/bluez/repo
url = https://github.com/bluez/bluez.git
branch = master
-[submodule "ot-commissioner"]
- path = third_party/ot-commissioner/repo
- url = https://github.com/openthread/ot-commissioner
- branch = main
[submodule "cirque"]
path = third_party/cirque/repo
url = https://github.com/openweave/cirque.git
diff --git a/.restyled.yaml b/.restyled.yaml
index 2b0a87ddaf51e8..179a12522885fe 100644
--- a/.restyled.yaml
+++ b/.restyled.yaml
@@ -63,7 +63,6 @@ exclude:
- "third_party/openthread/repo/**/*"
- "third_party/ot-br-posix/repo/**/*"
- "third_party/bluez/repo/**/*"
- - "third_party/ot-commissioner/repo/**/*"
- "third_party/cirque/repo/**/*"
- "third_party/nanopb/repo/**/*"
diff --git a/scripts/examples/android_app.sh b/scripts/examples/android_app.sh
index e716fe75c21332..8b8739618a00d9 100755
--- a/scripts/examples/android_app.sh
+++ b/scripts/examples/android_app.sh
@@ -42,7 +42,3 @@ ninja -C out/"android_$TARGET_CPU" src/setup_payload/java src/controller/java de
rsync -a out/"android_$TARGET_CPU"/lib/*.jar src/android/CHIPTool/app/libs
rsync -a out/"android_$TARGET_CPU"/lib/jni/* src/android/CHIPTool/app/src/main/jniLibs
-
-# Build ot-commissioner libs
-git submodule update --init --recursive third_party/ot-commissioner/repo
-TARGET_CPU=arm64 ./third_party/ot-commissioner/build-android-libs.sh
diff --git a/src/android/CHIPTool/README.md b/src/android/CHIPTool/README.md
index 721fd6d0a30332..ae7125bba87055 100644
--- a/src/android/CHIPTool/README.md
+++ b/src/android/CHIPTool/README.md
@@ -42,7 +42,6 @@ Complete the following steps to build CHIPTool:
2. In the command line, run the following command from the top CHIP directory:
```shell
- sudo apt-get install -y swig # "brew install swig" for macOS.
TARGET_CPU=arm64 ./scripts/examples/android_app.sh
```
diff --git a/src/android/CHIPTool/app/src/main/AndroidManifest.xml b/src/android/CHIPTool/app/src/main/AndroidManifest.xml
index b3ad31a0e4cbd6..1cee8e71b6eab0 100644
--- a/src/android/CHIPTool/app/src/main/AndroidManifest.xml
+++ b/src/android/CHIPTool/app/src/main/AndroidManifest.xml
@@ -31,11 +31,6 @@
-
-
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt
index 088ec59ebeff5c..cbfbe624ee78d6 100644
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt
+++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt
@@ -29,7 +29,6 @@ import androidx.fragment.app.Fragment
import chip.setuppayload.SetupPayloadParser.UnrecognizedQrCodeException
import com.google.chip.chiptool.attestation.AttestationTestFragment
import com.google.chip.chiptool.clusterclient.OnOffClientFragment
-import com.google.chip.chiptool.commissioner.CommissionerActivity
import com.google.chip.chiptool.echoclient.EchoClientFragment
import com.google.chip.chiptool.provisioning.DeviceProvisioningFragment
import com.google.chip.chiptool.provisioning.ProvisionNetworkType
@@ -106,11 +105,6 @@ class CHIPToolActivity :
showFragment(BarcodeFragment.newInstance(), false)
}
- override fun handleCommissioningClicked() {
- var intent = Intent(this, CommissionerActivity::class.java)
- startActivityForResult(intent, REQUEST_CODE_COMMISSIONING)
- }
-
override fun handleEchoClientClicked() {
showFragment(EchoClientFragment.newInstance())
}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/SelectActionFragment.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/SelectActionFragment.kt
index 375c41541c8cc4..7624db412cb84c 100644
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/SelectActionFragment.kt
+++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/SelectActionFragment.kt
@@ -50,7 +50,6 @@ class SelectActionFragment : Fragment() {
isEnabled = hasLocationPermission()
setOnClickListener { getCallback()?.onProvisionThreadCredentialsClicked() }
}
- otCommissioningBtn.setOnClickListener { getCallback()?.handleCommissioningClicked() }
echoClientBtn.setOnClickListener { getCallback()?.handleEchoClientClicked() }
onOffClusterBtn.setOnClickListener { getCallback()?.handleOnOffClicked() }
attestationTestBtn.setOnClickListener { getCallback()?.handleAttestationTestClicked() }
@@ -106,8 +105,6 @@ class SelectActionFragment : Fragment() {
fun onProvisionWifiCredentialsClicked()
/** Notifies listener of provision-Thread-credentials button click. */
fun onProvisionThreadCredentialsClicked()
- /** Notifies listener of Commissioning button click. */
- fun handleCommissioningClicked()
/** Notifies listener of Echo client button click. */
fun handleEchoClientClicked()
/** Notifies listener of send command button click. */
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/CommissionerActivity.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/CommissionerActivity.java
deleted file mode 100644
index 238c5f53011072..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/CommissionerActivity.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner;
-
-import android.content.Intent;
-import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.Fragment;
-import com.google.chip.chiptool.R;
-import com.google.chip.chiptool.commissioner.thread.internal.SelectNetworkFragment;
-import com.google.chip.chiptool.setuppayloadscanner.BarcodeFragment;
-import com.google.chip.chiptool.setuppayloadscanner.CHIPDeviceInfo;
-
-public class CommissionerActivity extends AppCompatActivity implements BarcodeFragment.Callback {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.commissioner_activity);
-
- if (savedInstanceState == null) {
- showFragment(new BarcodeFragment());
- }
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- }
-
- @Override
- public void onCHIPDeviceInfoReceived(@NonNull CHIPDeviceInfo deviceInfo) {
- showFragment(new SelectNetworkFragment(deviceInfo));
- }
-
- public void finishCommissioning(int resultCode) {
- Intent resultIntent = new Intent();
- setResult(resultCode, resultIntent);
- finish();
- }
-
- public void showFragment(Fragment fragment) {
- getSupportFragmentManager()
- .beginTransaction()
- .replace(R.id.commissioner_service_activity, fragment, fragment.getClass().getSimpleName())
- .addToBackStack(null)
- .commit();
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/NetworkCredential.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/NetworkCredential.java
deleted file mode 100644
index 59b129189a19e3..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/NetworkCredential.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner;
-
-public interface NetworkCredential {
- byte[] getEncoded();
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/BorderAgentInfo.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/BorderAgentInfo.java
deleted file mode 100644
index 8e2346fa99dc63..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/BorderAgentInfo.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class BorderAgentInfo implements Parcelable {
- public String discriminator;
- public String networkName;
- public byte[] extendedPanId;
- public InetAddress host;
- public int port;
-
- public BorderAgentInfo(
- @NonNull String discriminator,
- @NonNull String networkName,
- @NonNull byte[] extendedPanId,
- @NonNull InetAddress host,
- @NonNull int port) {
- this.discriminator = discriminator;
- this.networkName = networkName;
- this.extendedPanId = extendedPanId;
- this.host = host;
- this.port = port;
- }
-
- protected BorderAgentInfo(Parcel in) {
- discriminator = in.readString();
- networkName = in.readString();
- extendedPanId = in.createByteArray();
- try {
- host = InetAddress.getByAddress(in.createByteArray());
- } catch (UnknownHostException e) {
- }
- port = in.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(discriminator);
- dest.writeString(networkName);
- dest.writeByteArray(extendedPanId);
- dest.writeByteArray(host.getAddress());
- dest.writeInt(port);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- public boolean equals(BorderAgentInfo other) {
- return this.discriminator.equals(other.discriminator);
- }
-
- public static final Creator CREATOR =
- new Creator() {
- @Override
- public BorderAgentInfo createFromParcel(Parcel in) {
- return new BorderAgentInfo(in);
- }
-
- @Override
- public BorderAgentInfo[] newArray(int size) {
- return new BorderAgentInfo[size];
- }
- };
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/CommissionerUtils.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/CommissionerUtils.java
deleted file mode 100644
index 05c68880b106d6..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/CommissionerUtils.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread;
-
-import io.openthread.commissioner.ByteArray;
-
-public class CommissionerUtils {
-
- public static byte[] getByteArray(ByteArray byteArray) {
- byte[] ret = new byte[byteArray.size()];
- for (int i = 0; i < byteArray.size(); ++i) {
- ret[i] = byteArray.get(i);
- }
- return ret;
- }
-
- public static String getHexString(byte[] byteArray) {
- StringBuilder strbuilder = new StringBuilder();
-
- for (byte b : byteArray) {
- strbuilder.append(String.format("%02x", b));
- }
- return strbuilder.toString();
- }
-
- public static String getHexString(ByteArray byteArray) {
- return getHexString(getByteArray(byteArray));
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadCommissionerException.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadCommissionerException.java
deleted file mode 100644
index 9747ad2ccb6b72..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadCommissionerException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread;
-
-import androidx.annotation.NonNull;
-
-public class ThreadCommissionerException extends Exception {
-
- private final int code;
-
- @NonNull private final String message;
-
- public ThreadCommissionerException(int code, String message) {
- this.code = code;
- this.message = message;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getMessage() {
- return message;
- }
-
- @Override
- public String toString() {
- return String.format("[ %d ]: %s", code, message);
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadCommissionerService.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadCommissionerService.java
deleted file mode 100644
index 2d6aa4f02be1ed..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadCommissionerService.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import java.util.concurrent.CompletableFuture;
-
-public interface ThreadCommissionerService {
-
- // This method returns Credential of a given Thread Network.
- // If the Commissioner Service doesn't possess the Network
- // Credentials already, it will fetch the Credentials from
- // a Border Agent (assisting device) using the Thread
- // Commissioning protocol.
- //
- // The pskc is used to securely connect to the Border Agent device.
- // If no pskc is given, the user will be asked to input it.
- // The Network Credentials will be saved in the Commissioner
- // Service before returning.
- CompletableFuture FetchThreadNetworkCredential(
- @NonNull BorderAgentInfo borderAgentInfo, @Nullable byte[] pskc);
-
- // This method returns Credential of a given Thread Network stored in the database on the phone.
- CompletableFuture getThreadNetworkCredential(
- @NonNull BorderAgentInfo borderAgentInfo);
-
- // This method deletes Credential of a given Thread Network stored in the database on the phone.
- CompletableFuture deleteThreadNetworkCredential(@NonNull BorderAgentInfo borderAgentInfo);
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadCommissionerServiceFactory.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadCommissionerServiceFactory.java
deleted file mode 100644
index b2d4f9bd22a057..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadCommissionerServiceFactory.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread;
-
-import android.content.Context;
-import com.google.chip.chiptool.commissioner.thread.internal.ThreadCommissionerServiceImpl;
-
-class ThreadCommissionerServiceFactory {
- public ThreadCommissionerService getCommissionerService(Context context) {
- return new ThreadCommissionerServiceImpl(context);
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadNetworkCredential.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadNetworkCredential.java
deleted file mode 100644
index c36a8c99b8d3ed..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadNetworkCredential.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import com.google.chip.chiptool.commissioner.NetworkCredential;
-
-public class ThreadNetworkCredential implements NetworkCredential, Parcelable {
-
- @NonNull private final byte[] activeOperationalDataset;
-
- public ThreadNetworkCredential(@NonNull byte[] activeOperationalDataset) {
- this.activeOperationalDataset = activeOperationalDataset;
- }
-
- protected ThreadNetworkCredential(Parcel in) {
- activeOperationalDataset = in.createByteArray();
- }
-
- public static final Creator CREATOR =
- new Creator() {
- @Override
- public ThreadNetworkCredential createFromParcel(Parcel in) {
- return new ThreadNetworkCredential(in);
- }
-
- @Override
- public ThreadNetworkCredential[] newArray(int size) {
- return new ThreadNetworkCredential[size];
- }
- };
-
- public byte[] getActiveOperationalDataset() {
- return activeOperationalDataset;
- }
-
- @Override
- public byte[] getEncoded() {
- return activeOperationalDataset;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel parcel, int i) {
- parcel.writeByteArray(activeOperationalDataset);
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadNetworkInfo.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadNetworkInfo.java
deleted file mode 100644
index 77be670edc5e1a..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/ThreadNetworkInfo.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import androidx.annotation.NonNull;
-
-public class ThreadNetworkInfo implements Parcelable {
-
- @NonNull private final String networkName;
-
- @NonNull private final byte[] extendedPanId;
-
- public ThreadNetworkInfo(@NonNull String networkName, @NonNull byte[] extendedPanId) {
- this.networkName = networkName;
- this.extendedPanId = extendedPanId;
- }
-
- protected ThreadNetworkInfo(Parcel in) {
- networkName = in.readString();
- extendedPanId = in.createByteArray();
- }
-
- public String getNetworkName() {
- return networkName;
- }
-
- public byte[] getExtendedPanId() {
- return extendedPanId;
- }
-
- public static final Creator CREATOR =
- new Creator() {
- @Override
- public ThreadNetworkInfo createFromParcel(Parcel in) {
- return new ThreadNetworkInfo(in);
- }
-
- @Override
- public ThreadNetworkInfo[] newArray(int size) {
- return new ThreadNetworkInfo[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel parcel, int flags) {
- parcel.writeString(networkName);
- parcel.writeByteArray(extendedPanId);
- }
-
- @Override
- public String toString() {
- return String.format(
- "{name=%s, extendedPanId=%s}", networkName, CommissionerUtils.getHexString(extendedPanId));
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentDao.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentDao.java
deleted file mode 100644
index aba0a5b9c73efc..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentDao.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import androidx.annotation.NonNull;
-import androidx.lifecycle.LiveData;
-import androidx.room.Dao;
-import androidx.room.Insert;
-import androidx.room.OnConflictStrategy;
-import androidx.room.Query;
-import java.util.List;
-
-@Dao
-interface BorderAgentDao {
-
- @Query("SELECT * FROM border_agent_table ORDER BY network_name ASC")
- LiveData> getAll();
-
- @Query("SELECT * FROM border_agent_table WHERE discriminator=:discriminator LIMIT 1")
- BorderAgentRecord getBorderAgent(@NonNull String discriminator);
-
- @Query(
- "SELECT * FROM border_agent_table WHERE network_name=:networkName AND extended_pan_id=:extendedPanId")
- List getBorderAgents(
- @NonNull String networkName, @NonNull byte[] extendedPanId);
-
- @Insert(onConflict = OnConflictStrategy.IGNORE)
- void insert(BorderAgentRecord borderAgentRecord);
-
- @Query("DELETE FROM border_agent_table WHERE discriminator=:discriminator")
- void delete(@NonNull String discriminator);
-
- @Query("DELETE FROM border_agent_table")
- void deleteAll();
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentDatabase.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentDatabase.java
deleted file mode 100644
index 855d53d72412e9..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentDatabase.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.room.Database;
-import androidx.room.Room;
-import androidx.room.RoomDatabase;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-@Database(
- entities = {BorderAgentRecord.class},
- version = 1,
- exportSchema = false)
-abstract class BorderAgentDatabase extends RoomDatabase {
-
- abstract BorderAgentDao borderAgentDao();
-
- private static volatile BorderAgentDatabase INSTANCE;
- private static final int NUMBER_OF_THREADS = 2;
-
- static final ExecutorService executor = Executors.newFixedThreadPool(NUMBER_OF_THREADS);
-
- public static BorderAgentDatabase getDatabase(final Context context) {
- if (INSTANCE == null) {
- synchronized (BorderAgentDatabase.class) {
- if (INSTANCE == null) {
- INSTANCE =
- Room.databaseBuilder(
- context.getApplicationContext(),
- BorderAgentDatabase.class,
- "network_credential_database")
- .build();
- }
- }
- }
- return INSTANCE;
- }
-
- public CompletableFuture getBorderAgent(@NonNull String discriminator) {
- CompletableFuture future =
- CompletableFuture.supplyAsync(() -> borderAgentDao().getBorderAgent(discriminator));
- return future;
- }
-
- public CompletableFuture insertBorderAgent(@NonNull BorderAgentRecord borderAgentRecord) {
- CompletableFuture future =
- CompletableFuture.runAsync(
- () -> {
- borderAgentDao().insert(borderAgentRecord);
- },
- executor);
- return future;
- }
-
- public CompletableFuture deleteBorderAgent(@NonNull String discriminator) {
- CompletableFuture future =
- CompletableFuture.runAsync(
- () -> {
- borderAgentDao().delete(discriminator);
- },
- executor);
- return future;
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentDiscoverer.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentDiscoverer.java
deleted file mode 100644
index d4831e3d518321..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentDiscoverer.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.Manifest.permission;
-import android.content.Context;
-import android.net.nsd.NsdManager;
-import android.net.nsd.NsdServiceInfo;
-import android.net.wifi.WifiManager;
-import android.util.Log;
-import androidx.annotation.RequiresPermission;
-import com.google.chip.chiptool.commissioner.thread.BorderAgentInfo;
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-class BorderAgentDiscoverer implements NsdManager.DiscoveryListener {
-
- private static final String TAG = BorderAgentDiscoverer.class.getSimpleName();
-
- private static final String SERVICE_TYPE = "_meshcop._udp";
- private static final String KEY_DISCRIMINATOR = "discriminator";
- private static final String KEY_NETWORK_NAME = "nn";
- private static final String KEY_EXTENDED_PAN_ID = "xp";
-
- private WifiManager.MulticastLock wifiMulticastLock;
- private NsdManager nsdManager;
- private BorderAgentListener borderAgentListener;
-
- private ExecutorService executor = Executors.newSingleThreadExecutor();
- private BlockingQueue unresolvedServices = new ArrayBlockingQueue<>(256);
- private AtomicBoolean isResolvingService = new AtomicBoolean(false);
-
- private boolean isScanning = false;
-
- public interface BorderAgentListener {
- void onBorderAgentFound(BorderAgentInfo borderAgentInfo);
-
- void onBorderAgentLost(String discriminator);
- }
-
- @RequiresPermission(permission.INTERNET)
- public BorderAgentDiscoverer(Context context, BorderAgentListener borderAgentListener) {
- WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- wifiMulticastLock = wifi.createMulticastLock("multicastLock");
-
- nsdManager = (NsdManager) context.getSystemService(Context.NSD_SERVICE);
-
- this.borderAgentListener = borderAgentListener;
- }
-
- public void start() {
- if (isScanning) {
- Log.w(TAG, "the Border Agent discoverer is already running!");
- return;
- }
-
- isScanning = true;
-
- wifiMulticastLock.setReferenceCounted(true);
- wifiMulticastLock.acquire();
-
- startResolver();
- nsdManager.discoverServices(
- BorderAgentDiscoverer.SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, this);
- }
-
- private void startResolver() {
- NsdManager.ResolveListener listener =
- new NsdManager.ResolveListener() {
- @Override
- public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
- Log.e(
- TAG,
- String.format(
- "failed to resolve service %s, error: %d, this=%s",
- serviceInfo.toString(), errorCode, this));
- isResolvingService.set(false);
- }
-
- @Override
- public void onServiceResolved(NsdServiceInfo serviceInfo) {
- BorderAgentInfo borderAgent = getBorderAgentInfo(serviceInfo);
- if (borderAgent != null) {
- Log.d(TAG, "successfully resolved service: " + serviceInfo.toString());
- borderAgentListener.onBorderAgentFound(borderAgent);
- }
- isResolvingService.set(false);
- }
- };
-
- Log.d(TAG, "mDNS resolve listener is " + listener);
-
- if (executor.isTerminated()) {
- executor = Executors.newSingleThreadExecutor();
- }
-
- executor.submit(
- () -> {
- while (true) {
- if (!isResolvingService.get()) {
- NsdServiceInfo serviceInfo = unresolvedServices.take();
-
- isResolvingService.set(true);
- nsdManager.resolveService(serviceInfo, listener);
- }
- }
- });
- }
-
- private void stopResolver() {
- if (!executor.isTerminated()) {
- executor.shutdownNow();
- }
- isResolvingService.set(false);
- unresolvedServices.clear();
- }
-
- public void stop() {
- if (!isScanning) {
- Log.w(TAG, "the Border Agent discoverer has already been stopped!");
- return;
- }
-
- nsdManager.stopServiceDiscovery(this);
- stopResolver();
-
- if (wifiMulticastLock != null) {
- wifiMulticastLock.release();
- }
-
- isScanning = false;
- }
-
- @Override
- public void onDiscoveryStarted(String serviceType) {
- Log.d(TAG, "start discovering Border Agent");
- }
-
- @Override
- public void onDiscoveryStopped(String serviceType) {
- Log.d(TAG, "stop discovering Border Agent");
- }
-
- @Override
- public void onServiceFound(NsdServiceInfo nsdServiceInfo) {
- Log.d(TAG, "a Border Agent service found");
-
- unresolvedServices.offer(nsdServiceInfo);
- }
-
- @Override
- public void onServiceLost(NsdServiceInfo nsdServiceInfo) {
- String discriminator = getBorderAgentDiscriminator(nsdServiceInfo);
- if (discriminator != null) {
- Log.d(TAG, "a Border Agent service is gone");
- borderAgentListener.onBorderAgentLost(discriminator);
- }
- }
-
- @Override
- public void onStartDiscoveryFailed(String serviceType, int errorCode) {
- Log.d(TAG, "start discovering Border Agent failed: " + errorCode);
- }
-
- @Override
- public void onStopDiscoveryFailed(String serviceType, int errorCode) {
- Log.d(TAG, "stop discovering Border Agent failed: " + errorCode);
- }
-
- private BorderAgentInfo getBorderAgentInfo(NsdServiceInfo serviceInfo) {
- Map attrs = serviceInfo.getAttributes();
-
- // Use the host address as default discriminator.
- String discriminator = serviceInfo.getHost().getHostAddress();
-
- if (attrs.containsKey(KEY_DISCRIMINATOR)) {
- discriminator = new String(attrs.get(KEY_DISCRIMINATOR));
- }
-
- if (!attrs.containsKey(KEY_NETWORK_NAME) || !attrs.containsKey(KEY_EXTENDED_PAN_ID)) {
- return null;
- }
-
- return new BorderAgentInfo(
- discriminator,
- new String(attrs.get(KEY_NETWORK_NAME)),
- attrs.get(KEY_EXTENDED_PAN_ID),
- serviceInfo.getHost(),
- serviceInfo.getPort());
- }
-
- private String getBorderAgentDiscriminator(NsdServiceInfo serviceInfo) {
- Map attrs = serviceInfo.getAttributes();
-
- if (attrs.containsKey(KEY_DISCRIMINATOR)) {
- return new String(attrs.get(KEY_DISCRIMINATOR));
- }
-
- if (serviceInfo.getHost() != null) {
- // Use the host address as default discriminator.
- return serviceInfo.getHost().getHostAddress();
- }
-
- return null;
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentRecord.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentRecord.java
deleted file mode 100644
index 8037d5dc0686ca..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/BorderAgentRecord.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.room.ColumnInfo;
-import androidx.room.Entity;
-import androidx.room.PrimaryKey;
-
-@Entity(tableName = "border_agent_table")
-public class BorderAgentRecord {
-
- @PrimaryKey
- @NonNull
- @ColumnInfo(name = "discriminator")
- private String discriminator;
-
- @NonNull
- @ColumnInfo(name = "network_name")
- private String networkName;
-
- @NonNull
- @ColumnInfo(name = "extended_pan_id", typeAffinity = ColumnInfo.BLOB)
- private byte[] extendedPanId;
-
- @NonNull
- @ColumnInfo(name = "pskc", typeAffinity = ColumnInfo.BLOB)
- private byte[] pskc;
-
- @Nullable
- @ColumnInfo(name = "active_operational_dataset", typeAffinity = ColumnInfo.BLOB)
- private byte[] activeOperationalDataset;
-
- public BorderAgentRecord(
- @NonNull String discriminator,
- @NonNull String networkName,
- @NonNull byte[] extendedPanId,
- @NonNull byte[] pskc,
- @Nullable byte[] activeOperationalDataset) {
- this.discriminator = discriminator;
- this.networkName = networkName;
- this.extendedPanId = extendedPanId;
- this.pskc = pskc;
- this.activeOperationalDataset = activeOperationalDataset;
- }
-
- @NonNull
- public String getDiscriminator() {
- return discriminator;
- }
-
- @NonNull
- public String getNetworkName() {
- return networkName;
- }
-
- @NonNull
- public byte[] getExtendedPanId() {
- return extendedPanId;
- }
-
- @NonNull
- public byte[] getPskc() {
- return pskc;
- }
-
- @Nullable
- public byte[] getActiveOperationalDataset() {
- return activeOperationalDataset;
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/CommissioningFragment.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/CommissioningFragment.java
deleted file mode 100644
index c03d8a9f2c12de..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/CommissioningFragment.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-import com.google.chip.chiptool.R;
-import com.google.chip.chiptool.commissioner.CommissionerActivity;
-import com.google.chip.chiptool.commissioner.thread.ThreadNetworkCredential;
-
-public class CommissioningFragment extends Fragment {
-
- private static final String TAG = CommissioningFragment.class.getSimpleName();
-
- ThreadNetworkCredential networkCredential;
-
- CommissionerActivity commissionerActivity;
-
- TextView statusText;
- ProgressBar progressBar;
- Button cancelButton;
- Button doneButton;
- ImageView doneImage;
- ImageView errorImage;
-
- public CommissioningFragment(@NonNull ThreadNetworkCredential networkCredential) {
- this.networkCredential = networkCredential;
- }
-
- @Override
- public View onCreateView(
- LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.commissioner_commissioning_fragment, container, false);
- }
-
- @Override
- public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- commissionerActivity = (CommissionerActivity) getActivity();
-
- cancelButton = view.findViewById(R.id.cancel_button);
- doneButton = view.findViewById(R.id.done_button);
- doneImage = view.findViewById(R.id.done_image);
- errorImage = view.findViewById(R.id.error_image);
- statusText = view.findViewById(R.id.status_text);
- progressBar = view.findViewById(R.id.commissioning_progress);
-
- view.findViewById(R.id.cancel_button)
- .setOnClickListener(
- v -> {
- commissionerActivity.finishCommissioning(Activity.RESULT_CANCELED);
- });
-
- view.findViewById(R.id.done_button)
- .setOnClickListener(
- v -> {
- commissionerActivity.finishCommissioning(Activity.RESULT_OK);
- });
-
- // TODO: commissioning over BLE.
- showCommissionDone(false, "Commissioning over BLE not implemented yet!");
- }
-
- private void showInProgress(String status) {
- if (status != null) {
- statusText.setText(status);
- }
-
- progressBar.setVisibility(View.VISIBLE);
-
- cancelButton.setVisibility(View.VISIBLE);
- doneImage.setVisibility(View.GONE);
- errorImage.setVisibility(View.GONE);
- doneButton.setVisibility(View.GONE);
- }
-
- private void showCommissionDone(Boolean success, String status) {
- if (status != null) {
- statusText.setText(status);
- }
-
- progressBar.setVisibility(View.GONE);
- cancelButton.setVisibility(View.GONE);
- doneButton.setVisibility(View.VISIBLE);
-
- if (success) {
- doneImage.setVisibility(View.VISIBLE);
- errorImage.setVisibility(View.GONE);
- } else {
- doneImage.setVisibility(View.GONE);
- errorImage.setVisibility(View.VISIBLE);
- }
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/Constants.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/Constants.java
deleted file mode 100644
index 2eea3efd3d47b0..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/Constants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-class Constants {
- public static final String KEY_DEVICE_INFO = "deviceinfo";
-
- public static final String KEY_NETWORK_INFO = "networkinfo";
-
- public static final String KEY_PSKC = "pskc";
-
- public static final String KEY_COMMISSIONING_STATUS = "commissioning_status";
-
- public static final String KEY_SUCCESS = "success";
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/FetchCredentialDialogFragment.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/FetchCredentialDialogFragment.java
deleted file mode 100644
index 8cf03f73bf7c33..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/FetchCredentialDialogFragment.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.fragment.app.DialogFragment;
-import com.google.chip.chiptool.R;
-import com.google.chip.chiptool.commissioner.thread.BorderAgentInfo;
-import com.google.chip.chiptool.commissioner.thread.ThreadCommissionerException;
-import com.google.chip.chiptool.commissioner.thread.ThreadNetworkCredential;
-
-public class FetchCredentialDialogFragment extends DialogFragment
- implements DialogInterface.OnClickListener {
-
- private CredentialListener credentialListener;
- private TextView statusText;
-
- private AlertDialog dialog;
-
- NetworkCredentialFetcher fetcher = new NetworkCredentialFetcher();
- BorderAgentInfo borderAgentInfo;
- byte[] pskc;
- private ThreadNetworkCredential credential;
-
- public interface CredentialListener {
- void onCancelClick(FetchCredentialDialogFragment fragment);
-
- void onConfirmClick(FetchCredentialDialogFragment fragment, ThreadNetworkCredential credential);
- }
-
- public FetchCredentialDialogFragment(
- @NonNull BorderAgentInfo borderAgentInfo,
- @NonNull byte[] pskc,
- @NonNull CredentialListener credentialListener) {
- this.borderAgentInfo = borderAgentInfo;
- this.pskc = pskc;
- this.credentialListener = credentialListener;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- LayoutInflater inflater = requireActivity().getLayoutInflater();
- View view = inflater.inflate(R.layout.commissioner_fetch_credential_dialog, null);
-
- statusText = view.findViewById(R.id.fetch_credential_status);
-
- builder.setTitle("Fetching Credential");
- builder.setView(view);
- builder.setPositiveButton(R.string.commissioner_fetch_credential_done, this);
- builder.setNegativeButton(R.string.commissioner_fetch_credential_cancel, this);
-
- dialog = builder.create();
- return dialog;
- }
-
- @Override
- public void onStart() {
- super.onStart();
-
- dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
- startFetching();
- }
-
- @Override
- public void onStop() {
- super.onStop();
-
- stopFetching();
- }
-
- @Override
- public void onClick(DialogInterface dialogInterface, int which) {
- if (which == DialogInterface.BUTTON_POSITIVE) {
- credentialListener.onConfirmClick(this, credential);
- } else {
- stopFetching();
- credentialListener.onCancelClick(this);
- }
- }
-
- private void startFetching() {
- Thread thread =
- new Thread(
- () -> {
- new Handler(Looper.getMainLooper())
- .post(
- () -> {
- statusText.setText("petitioning...");
- });
-
- String status;
- try {
- credential = fetcher.fetchNetworkCredential(borderAgentInfo, pskc);
- status = "success";
- } catch (ThreadCommissionerException e) {
- status = e.getMessage();
- }
-
- final String statusCopy = status;
-
- new Handler(Looper.getMainLooper())
- .post(
- () -> {
- statusText.setText(statusCopy);
- dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
- });
- });
- thread.start();
- }
-
- private void stopFetching() {
- fetcher.cancel();
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/InputNetworkPasswordDialogFragment.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/InputNetworkPasswordDialogFragment.java
deleted file mode 100644
index 8a53df8369e47b..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/InputNetworkPasswordDialogFragment.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.EditText;
-import androidx.fragment.app.DialogFragment;
-import com.google.chip.chiptool.R;
-
-public class InputNetworkPasswordDialogFragment extends DialogFragment
- implements DialogInterface.OnClickListener {
-
- private PasswordDialogListener passwordListener;
- private EditText passwordText;
-
- public interface PasswordDialogListener {
- public void onPositiveClick(InputNetworkPasswordDialogFragment fragment, String password);
-
- public void onNegativeClick(InputNetworkPasswordDialogFragment fragment);
- }
-
- public InputNetworkPasswordDialogFragment(PasswordDialogListener passwordListener) {
- this.passwordListener = passwordListener;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- LayoutInflater inflater = requireActivity().getLayoutInflater();
- View view = inflater.inflate(R.layout.commissioner_network_password_dialog, null);
-
- passwordText = view.findViewById(R.id.network_password);
-
- builder.setTitle("Enter Password");
- builder.setView(view);
- builder.setPositiveButton(R.string.commissioner_password_connect, this);
- builder.setNegativeButton(R.string.commissioner_password_cancel, this);
-
- return builder.create();
- }
-
- @Override
- public void onClick(DialogInterface dialogInterface, int which) {
- if (which == DialogInterface.BUTTON_POSITIVE) {
- passwordListener.onPositiveClick(this, passwordText.getText().toString());
- } else {
- passwordListener.onNegativeClick(this);
- }
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/NetworkAdapter.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/NetworkAdapter.java
deleted file mode 100644
index e47bbae737d549..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/NetworkAdapter.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.content.Context;
-import android.os.Handler;
-import android.os.Looper;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.TextView;
-import com.google.chip.chiptool.R;
-import com.google.chip.chiptool.commissioner.thread.BorderAgentInfo;
-import com.google.chip.chiptool.commissioner.thread.internal.BorderAgentDiscoverer.BorderAgentListener;
-import java.util.Arrays;
-import java.util.Vector;
-
-class NetworkAdapter extends BaseAdapter implements BorderAgentListener {
- private Vector networks;
-
- private LayoutInflater inflater;
-
- NetworkAdapter(Context context) {
- inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- networks = new Vector<>();
- }
-
- public void addBorderAgent(BorderAgentInfo borderAgent) {
- boolean hasExistingNetwork = false;
- for (ThreadNetworkInfoHolder networkInfoHolder : networks) {
- if (networkInfoHolder.getNetworkInfo().getNetworkName().equals(borderAgent.networkName)
- && Arrays.equals(
- networkInfoHolder.getNetworkInfo().getExtendedPanId(), borderAgent.extendedPanId)) {
- networkInfoHolder.getBorderAgents().add(borderAgent);
- hasExistingNetwork = true;
- }
- }
-
- if (!hasExistingNetwork) {
- networks.add(new ThreadNetworkInfoHolder(borderAgent));
- }
-
- new Handler(Looper.getMainLooper()).post(() -> notifyDataSetChanged());
- }
-
- public void removeBorderAgent(String lostBorderAgentDisciminator) {
- for (ThreadNetworkInfoHolder networkInfoHolder : networks) {
- for (BorderAgentInfo borderAgent : networkInfoHolder.getBorderAgents()) {
- if (borderAgent.discriminator.equals(lostBorderAgentDisciminator)) {
- networkInfoHolder.getBorderAgents().remove(borderAgent);
- if (networkInfoHolder.getBorderAgents().isEmpty()) {
- networks.remove(networkInfoHolder);
- }
-
- new Handler(Looper.getMainLooper()).post(() -> notifyDataSetChanged());
- return;
- }
- }
- }
- }
-
- @Override
- public int getCount() {
- return networks.size();
- }
-
- @Override
- public Object getItem(int position) {
- return networks.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup container) {
- if (convertView == null) {
- convertView = inflater.inflate(R.layout.commissioner_network_list_item, container, false);
- }
- TextView networkNameText = convertView.findViewById(R.id.network_name);
- networkNameText.setText(networks.get(position).getNetworkInfo().getNetworkName());
- return convertView;
- }
-
- @Override
- public void onBorderAgentFound(BorderAgentInfo borderAgentInfo) {
- addBorderAgent(borderAgentInfo);
- }
-
- @Override
- public void onBorderAgentLost(String discriminator) {
- removeBorderAgent(discriminator);
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/NetworkCredentialFetcher.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/NetworkCredentialFetcher.java
deleted file mode 100644
index 1c2d174018c643..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/NetworkCredentialFetcher.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.util.Log;
-import androidx.annotation.NonNull;
-import com.google.chip.chiptool.commissioner.thread.BorderAgentInfo;
-import com.google.chip.chiptool.commissioner.thread.CommissionerUtils;
-import com.google.chip.chiptool.commissioner.thread.ThreadCommissionerException;
-import com.google.chip.chiptool.commissioner.thread.ThreadNetworkCredential;
-import io.openthread.commissioner.ByteArray;
-import io.openthread.commissioner.ChannelMask;
-import io.openthread.commissioner.Commissioner;
-import io.openthread.commissioner.CommissionerHandler;
-import io.openthread.commissioner.Config;
-import io.openthread.commissioner.Error;
-import io.openthread.commissioner.ErrorCode;
-import io.openthread.commissioner.LogLevel;
-import io.openthread.commissioner.Logger;
-import java.net.InetAddress;
-
-class NetworkCredentialFetcher {
-
- private static final String TAG = NetworkCredentialFetcher.class.getSimpleName();
-
- NativeCommissionerHandler nativeCommissionerHandler = new NativeCommissionerHandler();
- Commissioner nativeCommissioner;
-
- public ThreadNetworkCredential fetchNetworkCredential(
- @NonNull BorderAgentInfo borderAgentInfo, @NonNull byte[] pskc)
- throws ThreadCommissionerException {
- byte[] rawActiveDataset =
- fetchNetworkCredential(borderAgentInfo.host, borderAgentInfo.port, pskc);
- return new ThreadNetworkCredential(rawActiveDataset);
- }
-
- public void cancel() {
- if (nativeCommissioner != null) {
- Log.d(TAG, "cancel requesting credential");
- nativeCommissioner.cancelRequests();
- }
- }
-
- private byte[] fetchNetworkCredential(
- @NonNull InetAddress address, int port, @NonNull byte[] pskc)
- throws ThreadCommissionerException {
- nativeCommissioner = Commissioner.create(nativeCommissionerHandler);
-
- Config config = new Config();
- config.setId("TestComm");
- config.setDomainName("TestDomain");
- config.setEnableCcm(false);
- config.setEnableDtlsDebugLogging(true);
- config.setPSKc(new ByteArray(pskc));
- config.setLogger(new NativeCommissionerLogger());
-
- try {
- // Initialize the native commissioner
- throwIfFail(nativeCommissioner.init(config));
-
- // Petition to be the active commissioner in the Thread Network.
- String[] existingCommissionerId = new String[1];
- throwIfFail(
- nativeCommissioner.petition(existingCommissionerId, address.getHostAddress(), port));
-
- // Fetch Active Operational Dataset.
- ByteArray rawActiveDataset = new ByteArray();
- throwIfFail(nativeCommissioner.getRawActiveDataset(rawActiveDataset, 0xFFFF));
- nativeCommissioner.resign();
- nativeCommissioner = null;
- return CommissionerUtils.getByteArray(rawActiveDataset);
- } catch (ThreadCommissionerException e) {
- nativeCommissioner.resign();
- nativeCommissioner = null;
- throw e;
- }
- }
-
- private void throwIfFail(Error error) throws ThreadCommissionerException {
- if (error.getCode() != ErrorCode.kNone) {
- throw new ThreadCommissionerException(error.getCode().swigValue(), error.getMessage());
- }
- }
-}
-
-class NativeCommissionerLogger extends Logger {
- private static final String TAG = "NativeCommissioner";
-
- @Override
- public void log(LogLevel level, String region, String msg) {
- Log.d(TAG, String.format("[ %s ]: %s", region, msg));
- }
-}
-
-class NativeCommissionerHandler extends CommissionerHandler {
- private static final String TAG = NativeCommissionerHandler.class.getSimpleName();
-
- @Override
- public String onJoinerRequest(ByteArray joinerId) {
- Log.d(TAG, "A joiner is requesting commissioning");
- return "";
- }
-
- @Override
- public void onJoinerConnected(ByteArray joinerId, Error error) {
- Log.d(TAG, "A joiner is connected");
- }
-
- @Override
- public boolean onJoinerFinalize(
- ByteArray joinerId,
- String vendorName,
- String vendorModel,
- String vendorSwVersion,
- ByteArray vendorStackVersion,
- String provisioningUrl,
- ByteArray vendorData) {
- Log.d(TAG, "A joiner is finalizing");
- return true;
- }
-
- @Override
- public void onKeepAliveResponse(Error error) {
- Log.d(TAG, "received keep-alive response: " + error.toString());
- }
-
- @Override
- public void onPanIdConflict(String peerAddr, ChannelMask channelMask, int panId) {
- Log.d(TAG, "received PAN ID CONFLICT report");
- }
-
- @Override
- public void onEnergyReport(String aPeerAddr, ChannelMask aChannelMask, ByteArray aEnergyList) {
- Log.d(TAG, "received ENERGY SCAN report");
- }
-
- @Override
- public void onDatasetChanged() {
- Log.d(TAG, "Thread Network Dataset chanaged");
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/SelectNetworkFragment.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/SelectNetworkFragment.java
deleted file mode 100644
index cddfc99cd3e2b1..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/SelectNetworkFragment.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.Button;
-import android.widget.ListView;
-import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-import com.google.chip.chiptool.R;
-import com.google.chip.chiptool.commissioner.CommissionerActivity;
-import com.google.chip.chiptool.commissioner.thread.BorderAgentInfo;
-import com.google.chip.chiptool.commissioner.thread.CommissionerUtils;
-import com.google.chip.chiptool.commissioner.thread.ThreadNetworkCredential;
-import com.google.chip.chiptool.commissioner.thread.ThreadNetworkInfo;
-import com.google.chip.chiptool.setuppayloadscanner.CHIPDeviceInfo;
-import io.openthread.commissioner.ByteArray;
-import io.openthread.commissioner.Commissioner;
-import io.openthread.commissioner.Error;
-import io.openthread.commissioner.ErrorCode;
-import java.util.concurrent.ExecutionException;
-
-public class SelectNetworkFragment extends Fragment
- implements InputNetworkPasswordDialogFragment.PasswordDialogListener,
- FetchCredentialDialogFragment.CredentialListener,
- View.OnClickListener {
-
- private static final String TAG = SelectNetworkFragment.class.getSimpleName();
-
- private CHIPDeviceInfo deviceInfo;
-
- private NetworkAdapter networksAdapter;
-
- private ThreadNetworkInfoHolder selectedNetwork;
- private byte[] userInputPskc;
- private Button addDeviceButton;
-
- private BorderAgentDiscoverer borderAgentDiscoverer;
-
- public SelectNetworkFragment() {}
-
- public SelectNetworkFragment(CHIPDeviceInfo deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Log.d(TAG, "::onCreate");
-
- networksAdapter = new NetworkAdapter(getContext());
- borderAgentDiscoverer = new BorderAgentDiscoverer(getContext(), networksAdapter);
- borderAgentDiscoverer.start();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
-
- Log.d(TAG, "::onDestroy");
-
- borderAgentDiscoverer.stop();
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- Log.d(TAG, "::onResume");
-
- borderAgentDiscoverer.start();
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- Log.d(TAG, "::onPause");
-
- borderAgentDiscoverer.stop();
- }
-
- @Override
- public View onCreateView(
- LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.commissioner_select_network_fragment, container, false);
- }
-
- @Override
- public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- // Hide the button
- addDeviceButton = view.findViewById(R.id.add_device_button);
- addDeviceButton.setVisibility(View.GONE);
-
- String deviceInfoString =
- String.format(
- "version: %d\nvendorId: %d\nproductId: %d\nsetupPinCode: %d",
- deviceInfo.getVersion(),
- deviceInfo.getVendorId(),
- deviceInfo.getProductId(),
- deviceInfo.getSetupPinCode());
- TextView deviceInfoView = view.findViewById(R.id.device_info);
- deviceInfoView.setText(deviceInfoString);
-
- final ListView networkListView = view.findViewById(R.id.networks);
- networkListView.setAdapter(networksAdapter);
-
- networkListView.setOnItemClickListener(
- (AdapterView> adapterView, View v, int position, long id) -> {
- selectedNetwork = (ThreadNetworkInfoHolder) adapterView.getItemAtPosition(position);
- addDeviceButton.setVisibility(View.VISIBLE);
- });
-
- view.findViewById(R.id.add_device_button).setOnClickListener(this);
- }
-
- private void gotoCommissioning(@NonNull ThreadNetworkCredential credential) {
- CommissionerActivity commissionerActivity = (CommissionerActivity) getActivity();
- commissionerActivity.showFragment(new CommissioningFragment(credential));
- }
-
- // Click listeners for network password dialog.
-
- @Override
- public void onPositiveClick(InputNetworkPasswordDialogFragment fragment, String password) {
- BorderAgentInfo selectedBorderAgent = selectedNetwork.getBorderAgents().get(0);
- userInputPskc = computePskc(selectedNetwork.getNetworkInfo(), password);
- gotoFetchingCredential(selectedBorderAgent, userInputPskc);
- }
-
- @Override
- public void onNegativeClick(InputNetworkPasswordDialogFragment fragment) {
- CommissionerActivity commissionerActivity = (CommissionerActivity) getActivity();
- commissionerActivity.finishCommissioning(Activity.RESULT_CANCELED);
- }
-
- private byte[] computePskc(ThreadNetworkInfo threadNetworkInfo, String password) {
- ByteArray extendedPanId = new ByteArray(threadNetworkInfo.getExtendedPanId());
- ByteArray pskc = new ByteArray();
- Error error =
- Commissioner.generatePSKc(
- pskc, password, threadNetworkInfo.getNetworkName(), extendedPanId);
- if (error.getCode() != ErrorCode.kNone) {
- Log.e(
- TAG,
- String.format(
- "failed to generate PSKc: %s; network-name=%s, extended-pan-id=%s",
- error.toString(),
- threadNetworkInfo.getNetworkName(),
- CommissionerUtils.getHexString(threadNetworkInfo.getExtendedPanId())));
- } else {
- Log.d(
- TAG,
- String.format(
- "generated pskc=%s, network-name=%s, extended-pan-id=%s",
- CommissionerUtils.getHexString(pskc),
- threadNetworkInfo.getNetworkName(),
- CommissionerUtils.getHexString(threadNetworkInfo.getExtendedPanId())));
- }
-
- return CommissionerUtils.getByteArray(pskc);
- }
-
- private void gotoFetchingCredential(BorderAgentInfo borderAgentInfo, byte[] pskc) {
- new FetchCredentialDialogFragment(borderAgentInfo, pskc, SelectNetworkFragment.this)
- .show(getParentFragmentManager(), FetchCredentialDialogFragment.class.getSimpleName());
- }
-
- @Override
- public void onClick(View view) {
- try {
- BorderAgentInfo selectedBorderAgent = selectedNetwork.getBorderAgents().get(0);
- ThreadCommissionerServiceImpl commissionerService =
- new ThreadCommissionerServiceImpl(getContext());
- BorderAgentRecord borderAgentRecord =
- commissionerService.getBorderAgentRecord(selectedBorderAgent).get();
-
- if (borderAgentRecord != null && borderAgentRecord.getActiveOperationalDataset() != null) {
- gotoCommissioning(
- new ThreadNetworkCredential(borderAgentRecord.getActiveOperationalDataset()));
- } else if (borderAgentRecord != null && borderAgentRecord.getPskc() != null) {
- gotoFetchingCredential(selectedBorderAgent, borderAgentRecord.getPskc());
- } else {
- new InputNetworkPasswordDialogFragment(SelectNetworkFragment.this)
- .show(
- getParentFragmentManager(),
- InputNetworkPasswordDialogFragment.class.getSimpleName());
- }
- } catch (ExecutionException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void onCancelClick(FetchCredentialDialogFragment fragment) {
- // TODO:
- }
-
- @Override
- public void onConfirmClick(
- FetchCredentialDialogFragment fragment, ThreadNetworkCredential credential) {
- if (credential != null) {
- ThreadCommissionerServiceImpl commissionerService =
- new ThreadCommissionerServiceImpl(getContext());
- try {
- commissionerService
- .addThreadNetworkCredential(
- selectedNetwork.getBorderAgents().get(0), userInputPskc, credential)
- .get();
- } catch (ExecutionException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- gotoCommissioning(credential);
- } else {
- Log.w(TAG, "failed to fetch credentials");
- }
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/ThreadCommissionerServiceImpl.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/ThreadCommissionerServiceImpl.java
deleted file mode 100644
index 6dce7e13da30b7..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/ThreadCommissionerServiceImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import com.google.chip.chiptool.commissioner.thread.BorderAgentInfo;
-import com.google.chip.chiptool.commissioner.thread.ThreadCommissionerException;
-import com.google.chip.chiptool.commissioner.thread.ThreadCommissionerService;
-import com.google.chip.chiptool.commissioner.thread.ThreadNetworkCredential;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionException;
-
-public class ThreadCommissionerServiceImpl implements ThreadCommissionerService {
-
- private static final String TAG = ThreadCommissionerException.class.getSimpleName();
-
- private BorderAgentDatabase borderAgentDatabase;
-
- public ThreadCommissionerServiceImpl(@NonNull Context context) {
- this.borderAgentDatabase = BorderAgentDatabase.getDatabase(context);
- }
-
- @Override
- public CompletableFuture FetchThreadNetworkCredential(
- @NonNull BorderAgentInfo borderAgentInfo, @Nullable byte[] pskc) {
- return getThreadNetworkCredential(borderAgentInfo)
- .thenApply(
- credential -> {
- if (credential != null) {
- return credential;
- }
-
- NetworkCredentialFetcher credentialFetcher = new NetworkCredentialFetcher();
- try {
- credential = credentialFetcher.fetchNetworkCredential(borderAgentInfo, pskc);
- addThreadNetworkCredential(borderAgentInfo, pskc, credential).get();
- return credential;
- } catch (Exception ex) {
- throw new CompletionException(ex);
- }
- });
- }
-
- @Override
- public CompletableFuture getThreadNetworkCredential(
- @NonNull BorderAgentInfo borderAgentInfo) {
- return getBorderAgentRecord(borderAgentInfo)
- .thenApply(
- borderAgentRecord -> {
- if (borderAgentRecord == null) {
- return null;
- }
- return new ThreadNetworkCredential(borderAgentRecord.getActiveOperationalDataset());
- });
- }
-
- CompletableFuture getBorderAgentRecord(
- @NonNull BorderAgentInfo borderAgentInfo) {
- return borderAgentDatabase.getBorderAgent(borderAgentInfo.discriminator);
- }
-
- @Override
- public CompletableFuture deleteThreadNetworkCredential(
- @NonNull BorderAgentInfo borderAgentInfo) {
- return borderAgentDatabase.deleteBorderAgent(borderAgentInfo.discriminator);
- }
-
- // This method adds given Thread Network Credential into database on the phone.
- CompletableFuture addThreadNetworkCredential(
- @NonNull BorderAgentInfo borderAgentInfo,
- @NonNull byte[] pskc,
- @NonNull ThreadNetworkCredential networkCredential) {
- BorderAgentRecord borderAgentRecord =
- new BorderAgentRecord(
- borderAgentInfo.discriminator,
- borderAgentInfo.networkName,
- borderAgentInfo.extendedPanId,
- pskc,
- networkCredential.getEncoded());
- return borderAgentDatabase.insertBorderAgent(borderAgentRecord);
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/ThreadNetworkInfoHolder.java b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/ThreadNetworkInfoHolder.java
deleted file mode 100644
index b0dec240a2d211..00000000000000
--- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/commissioner/thread/internal/ThreadNetworkInfoHolder.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2020 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.google.chip.chiptool.commissioner.thread.internal;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import com.google.chip.chiptool.commissioner.thread.BorderAgentInfo;
-import com.google.chip.chiptool.commissioner.thread.ThreadNetworkInfo;
-import java.util.ArrayList;
-
-class ThreadNetworkInfoHolder implements Parcelable {
- @NonNull private final ThreadNetworkInfo networkInfo;
-
- @NonNull private final ArrayList borderAgents;
-
- public ThreadNetworkInfoHolder(BorderAgentInfo borderAgent) {
- networkInfo = new ThreadNetworkInfo(borderAgent.networkName, borderAgent.extendedPanId);
- borderAgents = new ArrayList<>();
- borderAgents.add(borderAgent);
- }
-
- protected ThreadNetworkInfoHolder(Parcel in) {
- networkInfo = in.readParcelable(ThreadNetworkInfo.class.getClassLoader());
- borderAgents = in.createTypedArrayList(BorderAgentInfo.CREATOR);
- }
-
- public static final Creator CREATOR =
- new Creator() {
- @Override
- public ThreadNetworkInfoHolder createFromParcel(Parcel in) {
- return new ThreadNetworkInfoHolder(in);
- }
-
- @Override
- public ThreadNetworkInfoHolder[] newArray(int size) {
- return new ThreadNetworkInfoHolder[size];
- }
- };
-
- public ThreadNetworkInfo getNetworkInfo() {
- return networkInfo;
- }
-
- public ArrayList getBorderAgents() {
- return borderAgents;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeParcelable(networkInfo, flags);
- dest.writeParcelableArray((BorderAgentInfo[]) borderAgents.toArray(), flags);
- }
-}
diff --git a/src/android/CHIPTool/app/src/main/res/layout/commissioner_activity.xml b/src/android/CHIPTool/app/src/main/res/layout/commissioner_activity.xml
deleted file mode 100644
index e23acbc831101f..00000000000000
--- a/src/android/CHIPTool/app/src/main/res/layout/commissioner_activity.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
diff --git a/src/android/CHIPTool/app/src/main/res/layout/commissioner_commissioning_fragment.xml b/src/android/CHIPTool/app/src/main/res/layout/commissioner_commissioning_fragment.xml
deleted file mode 100644
index 0437721f561160..00000000000000
--- a/src/android/CHIPTool/app/src/main/res/layout/commissioner_commissioning_fragment.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/android/CHIPTool/app/src/main/res/layout/commissioner_fetch_credential_dialog.xml b/src/android/CHIPTool/app/src/main/res/layout/commissioner_fetch_credential_dialog.xml
deleted file mode 100644
index 07d14722c8e0e0..00000000000000
--- a/src/android/CHIPTool/app/src/main/res/layout/commissioner_fetch_credential_dialog.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/android/CHIPTool/app/src/main/res/layout/commissioner_network_list_item.xml b/src/android/CHIPTool/app/src/main/res/layout/commissioner_network_list_item.xml
deleted file mode 100644
index 7c980b44f7ef8e..00000000000000
--- a/src/android/CHIPTool/app/src/main/res/layout/commissioner_network_list_item.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/android/CHIPTool/app/src/main/res/layout/commissioner_network_password_dialog.xml b/src/android/CHIPTool/app/src/main/res/layout/commissioner_network_password_dialog.xml
deleted file mode 100644
index 095d056e5ec905..00000000000000
--- a/src/android/CHIPTool/app/src/main/res/layout/commissioner_network_password_dialog.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/android/CHIPTool/app/src/main/res/layout/commissioner_select_network_fragment.xml b/src/android/CHIPTool/app/src/main/res/layout/commissioner_select_network_fragment.xml
deleted file mode 100644
index 19b22538a19562..00000000000000
--- a/src/android/CHIPTool/app/src/main/res/layout/commissioner_select_network_fragment.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/android/CHIPTool/app/src/main/res/layout/select_action_fragment.xml b/src/android/CHIPTool/app/src/main/res/layout/select_action_fragment.xml
index eaf10fa23b2716..187e14a54049e8 100644
--- a/src/android/CHIPTool/app/src/main/res/layout/select_action_fragment.xml
+++ b/src/android/CHIPTool/app/src/main/res/layout/select_action_fragment.xml
@@ -27,14 +27,6 @@
android:layout_marginTop="8dp"
android:text="@string/provision_thread_credentials_btn_text" />
-
-
Network commissioning failed
- Open Thread Commissioning
- Commissioner
- Scan Device
- Cancel
- Done
- Please scan the QR code on the device
- Your Device
- Select Network
- Add Device
- Scan QR Code
- Select Network
- password
- connect
- cancel
- done
- cancel
- Commissioning
- Location permission missing
- Location permission is required to scan BLE devices.
- Try again
-
Attestation Test
Fetching…
No attestation app found
diff --git a/third_party/ot-commissioner/build-android-libs.sh b/third_party/ot-commissioner/build-android-libs.sh
deleted file mode 100755
index 4ab251083fc9f3..00000000000000
--- a/third_party/ot-commissioner/build-android-libs.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/bash
-
-readonly CUR_DIR="$(dirname "$(realpath -s "$0")")"
-
-set -e
-
-case "$TARGET_CPU" in
- arm)
- TARGET_ABI="armeabi-v7a"
- ;;
- arm64)
- TARGET_ABI="arm64-v8a"
- ;;
- x86)
- TARGET_ABI="x86"
- ;;
- x64)
- TARGET_ABI="x86-64"
- ;;
- *)
- echo "invalid TARGET_CPU value: $TARGET_CPU"
- exit 1
- ;;
-esac
-
-readonly BUILD_DIR=".build_$TARGET_CPU"
-
-cd "$CUR_DIR"
-
-mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
-cmake -GNinja \
- -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME"/build/cmake/android.toolchain.cmake \
- -DANDROID_ABI="$TARGET_ABI" \
- -DANDROID_ARM_NEON=ON \
- -DANDROID_NATIVE_API_LEVEL=24 \
- -DBUILD_SHARED_LIBS=OFF \
- -DCMAKE_CXX_STANDARD=11 \
- -DCMAKE_CXX_STANDARD_REQUIRED=ON \
- -DCMAKE_BUILD_TYPE=Release \
- -DOT_COMM_ANDROID=ON \
- -DOT_COMM_JAVA_BINDING=ON \
- -DOT_COMM_APP=OFF \
- -DOT_COMM_TEST=OFF \
- -DOT_COMM_CCM=OFF \
- ../repo
-
-ninja
-cd ../
-
-rm -rf "$BUILD_DIR"/libs && mkdir -p "$BUILD_DIR"/libs
-
-## Create JAR library
-javac -source 8 -target 8 "$BUILD_DIR"/src/java/io/openthread/commissioner/*.java
-
-cd "$BUILD_DIR"/src/java
-find ./io/openthread/commissioner -name "*.class" | xargs jar cvf ../../libs/libotcommissioner.jar
-cd ../../../
-
-## Copy shared native libraries
-rsync -a "$BUILD_DIR"/src/java/libcommissioner-java.so "$BUILD_DIR"/libs
-
-rsync -a "$BUILD_DIR"/libs/libotcommissioner.jar ../../src/android/CHIPTool/app/libs
-rsync -a "$BUILD_DIR"/libs/*.so ../../src/android/CHIPTool/app/src/main/jniLibs/"$TARGET_ABI"
diff --git a/third_party/ot-commissioner/repo b/third_party/ot-commissioner/repo
deleted file mode 160000
index b151bb5c66c9e5..00000000000000
--- a/third_party/ot-commissioner/repo
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit b151bb5c66c9e54fac64c531cd571e45bb8794a9