I am developing an app to store and clear Thread Network Credentials by implementing Thread Network SDK for Android.
App will check if there's any preferred credential when the app is launched up. Preferred credential can be retrieved, but it has an issue when it comes to remove it.
The app has a dedicated button to remove all the stored credentials. Per the log, credential has been removed succesfully. But, when I tried to get all credentials to check it, it still there and seems clearing credential function did not done properly.
Following is the log.
2023-06-07 17:22:41.184 9223-9223 ThreadN...rkFragment com.example.threadnetwork D context this: com.example.threadnetwork.MainActivity@a9e7519, context: com.example.threadnetwork.MainActivity@a9e7519
2023-06-07 17:22:41.252 9223-9223 ThreadN...rkFragment com.example.threadnetwork D getting all credentials: 1
2023-06-07 17:22:41.254 9223-9223 ThreadN...rkFragment com.example.threadnetwork D Thread Network Name:11, size xPan Id:8, xPanId:1111111122222222
2023-06-07 17:22:41.258 9223-9223 ThreadN...rkFragment com.example.threadnetwork D Thread Network: 11 is removed
2023-06-07 17:22:41.259 9223-9223 ThreadN...rkFragment com.example.threadnetwork D All credentials has been removed
2023-06-07 17:22:41.271 9223-9248 EGL_emulation com.example.threadnetwork D eglMakeCurrent: 0xa55c6aa0: ver 3 0 (tinfo 0xa996ce60)
2023-06-07 17:22:41.287 9223-9248 EGL_emulation com.example.threadnetwork D eglMakeCurrent: 0xa55c6aa0: ver 3 0 (tinfo 0xa996ce60)
2023-06-07 17:22:41.310 9223-9223 hreadN...rkFragment com.example.threadnetwork D getting all credentials: 1
Here's the snippet of how I remove the credential.
val networkClient = ThreadNetwork.getClient(context)
networkClient.allCredentials
.addOnSuccessListener { credentials -> for (i in credentials) {
Log.d (TAG, String.format ("getting all credentials: %s", credentials.size))
Log.d (TAG, String.format ("Thread Network Name:%s, size xPan Id:%s, xPanId:%s", i.networkName, i.extendedPanId.size, i.extendedPanId.toHexString()))
val threadBorderAgent = ThreadBorderAgent.newBuilder(i.extendedPanId.toHexString().toByteArray()).build()
networkClient.removeCredentials(threadBorderAgent)
Log.d(TAG, String.format ("Thread Network: %s is removed", i.networkName))
checkingCredentials (context)
}
Log.d (TAG, "All credentials has been removed")
Toast.makeText(this, "All credentials have been removed.", Toast.LENGTH_SHORT).show()
}
.addOnFailureListener{e:Exception -> Log.e (TAG, "Error happened: " + e.toString())}
I had tried to check this issue on AVD and phone. Both is having same behavior, all credentials cannot be removed sucessfully.
If anyone knows about this, your help is much appreciated. Thanks!